本文整理汇总了Java中java.util.Collections.synchronizedCollection方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.synchronizedCollection方法的具体用法?Java Collections.synchronizedCollection怎么用?Java Collections.synchronizedCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.synchronizedCollection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilterdMessage
import java.util.Collections; //导入方法依赖的package包/类
public static Collection<Object> getFilterdMessage(Collection<Object> sendMsgs,
Collection<Object> recvMsgs) {
Collection<Object> recvMsgsSync = Collections.synchronizedCollection(recvMsgs);
Collection<Object> filterdMsgs = new ArrayList<Object>();
int filterNum = 0;
for (Object msg : recvMsgsSync) {
if (sendMsgs.contains(msg)) {
filterdMsgs.add(msg);
} else {
filterNum++;
}
}
logger.info(String.format("[%s] messages is filterd!", filterNum));
return filterdMsgs;
}
示例2: findRoot
import java.util.Collections; //导入方法依赖的package包/类
@NbBundle.Messages({
"TXT_JavadocSearch=Searching Javadoc in {0}"
})
private static Collection<? extends URL> findRoot(final File file, final int type) throws MalformedURLException {
if (type != CLASSPATH) {
final FileObject fo = URLMapper.findFileObject(FileUtil.urlForArchiveOrDir(file));
if (fo != null) {
final Collection<FileObject> result = Collections.synchronizedCollection(new ArrayList<FileObject>());
if (type == SOURCES) {
final FileObject root = JavadocAndSourceRootDetection.findSourceRoot(fo);
if (root != null) {
result.add(root);
}
} else if (type == JAVADOC) {
final AtomicBoolean cancel = new AtomicBoolean();
class Task implements ProgressRunnable<Void>, Cancellable {
@Override
public Void run(ProgressHandle handle) {
result.addAll(JavadocAndSourceRootDetection.findJavadocRoots(fo, cancel));
return null;
}
@Override
public boolean cancel() {
cancel.set(true);
return true;
}
}
final ProgressRunnable<Void> task = new Task();
ProgressUtils.showProgressDialogAndRun(task, Bundle.TXT_JavadocSearch(file.getAbsolutePath()), false);
}
if (!result.isEmpty()) {
return result.stream()
.map(FileObject::toURL)
.collect(Collectors.toList());
}
}
}
return Collections.singleton(Utilities.toURI(file).toURL());
}
示例3: startImageLoader
import java.util.Collections; //导入方法依赖的package包/类
public void startImageLoader()
{
running.set(true);
threads = Collections.synchronizedCollection(new ArrayList<Thread>(this.concurrency));
for (int i = 0; i < this.concurrency; i++)
{
Thread thread = new Thread(this, String.format("ImageLoader_%d", i));
threads.add(thread);
thread.start();
}
}
示例4: SyncCollection
import java.util.Collections; //导入方法依赖的package包/类
/**
* Ctor.
* @param src An {@link Iterable}
*/
public SyncCollection(final Collection<T> src) {
super(
new SyncScalar<>(
() -> {
final Collection<T> temp = new LinkedList<>();
temp.addAll(src);
return Collections.synchronizedCollection(temp);
}
)
);
}
示例5: addPositionListener
import java.util.Collections; //导入方法依赖的package包/类
@Override
public void addPositionListener(IPositionListener l) {
if (posListeners == null) {
posListeners = Collections.synchronizedCollection(new LinkedHashSet<>());
}
posListeners.add(l);
}
示例6: closeAllSessions
import java.util.Collections; //导入方法依赖的package包/类
public static void closeAllSessions() {
try {//I CAN AND IT'S FREE BITCHES
Collection<IoSession> sss = Collections.synchronizedCollection(outGame.values());
synchronized (sss) {
final Iterator<IoSession> outIt = sss.iterator();
while (outIt.hasNext()) {
outIt.next().close();
outIt.remove();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: addMalcolmListener
import java.util.Collections; //导入方法依赖的package包/类
public void addMalcolmListener(IMalcolmListener<MalcolmEventBean> l) {
if (listeners==null) listeners = Collections.synchronizedCollection(new LinkedHashSet<IMalcolmListener<MalcolmEventBean>>());
listeners.add(l);
}
示例8: addRunListener
import java.util.Collections; //导入方法依赖的package包/类
@Override
public void addRunListener(IRunListener l) {
if (rlisteners==null) rlisteners = Collections.synchronizedCollection(new LinkedHashSet<>());
rlisteners.add(l);
}
示例9: getObject
import java.util.Collections; //导入方法依赖的package包/类
protected Collection<String> getObject() {
List<String> list = Collections.singletonList("string");
return Collections.synchronizedCollection(list);
}
示例10: getAnotherObject
import java.util.Collections; //导入方法依赖的package包/类
protected Collection<String> getAnotherObject() {
List<String> list = Collections.emptyList();
return Collections.synchronizedCollection(list);
}