Is using of parallel stream insdead of executor services in Java considered as bad practice? Why?
As you know myList.parallelStream().map(e -> ...)
will use ForkJoinPool.common()
under the hood. So if you will use at least two parallel streams at the same time you can face issues when:
map
function is blocking. But there is ForkJoinPool.ManagedBlocker as a rescue.map
function can be very CPU intensive which will cause other parallel streams to starve. Is there any way to set priority amongRecursiveTask
s or betweenForkJoinPool
s?
In other hand you can create as many ForkJoinPool
s as you want. new ForkJoinPool(4).submit(() -> myList.parallelStream()...
. Is it considered performance-wise to use multiple ForkJoinPool
s at one JVM?
Update
Use or not parallel stream = use or not ForkJoinPool, right? I found this and this links pretty useful to asnwer the last question