This question is exactly the same as this one, which wasn't actually answered (that code only uses one thread). My code looks like this at the moment
CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> {
foo.stream().parallel()
.forEach(bar -> {
//business logic
}
);
return null;
}, new TraceableExecutorService(this.beanFactory, Executors.newFixedThreadPool(threads), "fooBarStream"));
completableFuture.get();
yet only one thread is correctly traced. Using .parallelStream()
or a LazyTraceExecutor
directly instead of a TraceableExecutorService
didn't help.