當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。