use of net.openhft.chronicle.threads.NamedThreadFactory in project Chronicle-Queue by OpenHFT.
the class Queue30Test method testMT.
@Ignore("Stress test - doesn't finish")
@Test
public void testMT() throws IOException, InterruptedException {
try (final ChronicleQueue queue = SingleChronicleQueueBuilder.text(getTmpDir()).blockSize(640_000).build()) {
ExecutorService exec = Executors.newCachedThreadPool(new NamedThreadFactory("stress"));
Throwable[] tref = { null };
Runnable r = () -> {
try {
final String name = Thread.currentThread().getName();
final ExcerptAppender appender = queue.acquireAppender();
for (int count = 0; !Thread.currentThread().isInterrupted(); count++) {
final int c = count;
appender.writeDocument(w -> w.write(() -> "thread").text(name).write(() -> "count").int32(c));
if (count % 10_000 == 0) {
LOGGER.info(name + "> " + count);
}
}
} catch (Throwable t) {
tref[0] = t;
exec.shutdown();
}
};
for (int i = 0; i < 100; i++) exec.submit(r);
exec.awaitTermination(10, TimeUnit.MINUTES);
exec.shutdownNow();
if (tref[0] != null)
throw new AssertionError(tref[0]);
}
}
Aggregations