use of com.hazelcast.util.collection.LongHashSet in project hazelcast by hazelcast.
the class IdGeneratorStressTest method testMultipleThreads.
@Test
public void testMultipleThreads() throws ExecutionException, InterruptedException {
pickIdGenerator().init(13013);
List<Future> futureList = new ArrayList<Future>(THREAD_COUNT);
for (int i = 0; i < THREAD_COUNT; i++) {
IdGenerator idGenerator = pickIdGenerator();
IdGeneratorCallable callable = new IdGeneratorCallable(idGenerator);
Future<long[]> future = spawn(callable);
futureList.add(future);
}
LongHashSet totalGeneratedIds = new LongHashSet(TOTAL_ID_GENERATED, -1);
for (Future<long[]> future : futureList) {
long[] generatedIds = future.get();
for (long generatedId : generatedIds) {
assertTrue("ID: " + generatedId, totalGeneratedIds.add(generatedId));
}
}
assertEquals(TOTAL_ID_GENERATED, totalGeneratedIds.size());
}
Aggregations