当前位置: 首页>>代码示例>>Java>>正文


Java Collections.synchronizedCollection方法代码示例

本文整理汇总了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;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:17,代码来源:VerifyUtils.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:J2SEPlatformCustomizer.java

示例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();
	}
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:14,代码来源:ImageLoader.java

示例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);
            }
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:16,代码来源:SyncCollection.java

示例5: addPositionListener

import java.util.Collections; //导入方法依赖的package包/类
@Override
public void addPositionListener(IPositionListener l) {
	if (posListeners == null) {
		posListeners = Collections.synchronizedCollection(new LinkedHashSet<>());
	}
	posListeners.add(l);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:8,代码来源:AbstractRunnableDevice.java

示例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();
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:15,代码来源:GMServer.java

示例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);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:5,代码来源:MalcolmEventDelegate.java

示例8: addRunListener

import java.util.Collections; //导入方法依赖的package包/类
@Override
public void addRunListener(IRunListener l) {
	if (rlisteners==null) rlisteners = Collections.synchronizedCollection(new LinkedHashSet<>());
	rlisteners.add(l);
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:6,代码来源:AbstractRunnableDevice.java

示例9: getObject

import java.util.Collections; //导入方法依赖的package包/类
protected Collection<String> getObject() {
    List<String> list = Collections.singletonList("string");
    return Collections.synchronizedCollection(list);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:java_util_Collections_SynchronizedCollection.java

示例10: getAnotherObject

import java.util.Collections; //导入方法依赖的package包/类
protected Collection<String> getAnotherObject() {
    List<String> list = Collections.emptyList();
    return Collections.synchronizedCollection(list);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:java_util_Collections_SynchronizedCollection.java


注:本文中的java.util.Collections.synchronizedCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。