Top.Deck :
I'm using parallel stream on a List. I suppose it will use WorkJoinPool to spawn multiple work threads, somehow there's only one thread all the time according to the log:
14:32:14.561 [http-nio-8080-exec-146] INFO from parent_thread
14:32:15.071 [http-nio-8080-exec-146] INFO from first_element_execution
14:32:15.228 [http-nio-8080-exec-146] INFO from second_element_execution
... and so on.
Here's the short version of my code:
List<String> myList = ...;
myList.parallelStream().forEach( // Do something and slf4j.log it );
[EDITED] I've tried some very simple code on my local machine and it does spawn multiple threads. Unfortunately I couldn't run the production code neither on my local nor some other environment..
Why doesn't my parallelStream use WorkJoinPool to spawn multiple threads?
Thank you!
mxst4 :
It depends on how many cores your CPU on production has. You are using common ForkJoinPool which is initialised by expression: number of available processors - 1. So probably this thread pool has only 1 thread.