I have determined that using a parallel stream is indeed faster than a serial stream for my data set. With that said, I'm wondering about the ForkJoinPool used as is discussed in this question: Custom thread pool in Java 8 parallel stream.
Given,
void foo()
{
barCollection.parallelStream() … do something with the stream
}
are 1 & 2 below equivalent with respect to which pool will be used?
1)
ForkJoinPool.commonPool().submit(()->foo()).get();
2)
foo();
If the answer is yes, then why does the ForkJoinPol.commonPool()
method exist?