List of usage examples for java.util Collections synchronizedSet
public static <T> Set<T> synchronizedSet(Set<T> s)
From source file:org.janusgraph.graphdb.idmanagement.RidGenerationTest.java
@Test public void testThreadBasedRidGeneration() throws InterruptedException { Configuration c = Configuration.EMPTY; int n = 8;/*from ww w .j a va 2s . co m*/ Preconditions.checkArgument(1 < n); // n <= 1 is useless Collection<byte[]> rids = Collections.synchronizedSet(new HashSet<byte[]>()); RidThread[] threads = new RidThread[n]; for (int i = 0; i < n; i++) { threads[i] = new RidThread(rids, c); } for (int i = 0; i < n; i++) { threads[i].start(); } for (int i = 0; i < n; i++) { threads[i].join(); } //TODO: rewrite test case in terms of GraphDatabaseConfiguration //assertEquals(n, rids.size()); }
From source file:org.quickserver.util.pool.BasicObjectPool.java
public BasicObjectPool() { activeObjects = Collections.synchronizedSet(new HashSet()); idleObjects = Collections.synchronizedSet(new HashSet()); config = new Config(); }
From source file:descriptordump.dumpexecutor.AbstractExecutor.java
protected AbstractExecutor(TABLE_ID tid, TABLE_ID... tids) { List<TABLE_ID> t = new ArrayList<>(); if (tid != null) { t.add(tid);/* www . j av a 2 s . co m*/ } else { throw new NullPointerException("ID??????"); } if (tids != null) { t.addAll(Arrays.asList(tids)); } Set<TABLE_ID> temp = Collections.synchronizedSet(new HashSet<>()); temp.addAll(t); this.tids = Collections.unmodifiableSet(temp); }
From source file:com.application.maskhos.maskhosblogapi.Model.interfaces.BitmapCache.BitmapMemoryLruCache.java
BitmapMemoryLruCache(int maxSize, BitmapLruCache.RecyclePolicy policy) { super(maxSize); mRecyclePolicy = policy;//from ww w .j a va 2s . c o m mRemovedEntries = policy.canInBitmap() ? Collections.synchronizedSet(new HashSet<SoftReference<CacheableBitmapDrawable>>()) : null; }
From source file:org.robospring.inject.InjectionMetadata.java
public InjectionMetadata(Class targetClass, Collection<AbstractInjectedElement> elements) { this.injectedElements = Collections.synchronizedSet(new LinkedHashSet<AbstractInjectedElement>()); for (AbstractInjectedElement element : elements) { if (logger.isDebugEnabled()) { logger.debug("Found injected element on class [" + targetClass.getName() + "]: " + element); }/*from w w w . ja v a 2 s . c o m*/ this.injectedElements.add(element); } }
From source file:com.schedjoules.eventdiscovery.framework.googleapis.BasicGoogleApis.java
public BasicGoogleApis(FragmentActivity activity, Api... apis) { mActivity = activity;/*w ww . j a v a 2 s . c o m*/ mApis = Collections.synchronizedSet(new HashSet<>(Arrays.asList(apis))); mGoogleApiClient = new ThreadSafeLazy<>(new GoogleApiClientFactory()); }
From source file:framework.retrieval.engine.pool.impl.IndexWriterPool.java
public IndexWriterPool(IIndexReaderPool indexReaderPool) { methodInterceptorPoolMap = Collections.synchronizedMap(new HashMap<String, IndexWriterProxy>()); indexPathTypes = Collections.synchronizedSet(new HashSet<String>()); this.indexReaderPool = indexReaderPool; }
From source file:framework.retrieval.engine.pool.impl.IndexReaderPool.java
public IndexReaderPool() { methodInterceptorPoolMap = Collections.synchronizedMap(new HashMap<String, IndexReaderProxy>()); indexPathTypes = Collections.synchronizedSet(new HashSet<String>()); }
From source file:com.espertech.esper.pattern.pool.PatternSubexpressionPoolEngineSvc.java
public PatternSubexpressionPoolEngineSvc(long maxPoolCountConfigured, boolean preventStart) { this.maxPoolCountConfigured = maxPoolCountConfigured; this.preventStart = preventStart; this.poolCount = new AtomicLong(); this.patternContexts = Collections.synchronizedSet(new HashSet<StatementEntry>()); }
From source file:com.espertech.esper.rowregex.MatchRecognizeStatePoolEngineSvc.java
public MatchRecognizeStatePoolEngineSvc(long maxPoolCountConfigured, boolean preventStart) { this.maxPoolCountConfigured = maxPoolCountConfigured; this.preventStart = preventStart; this.poolCount = new AtomicLong(); this.matchRecognizeContexts = Collections.synchronizedSet(new HashSet<StatementEntry>()); }