I've seen a bunch of examples on the internet that, in order to use the streams API to do parallel stuff, just call the .parallelStream() method like this:
mySet
.parallelStream()
... // do my fancy stuff and collect
But in other cases I've seen the parallel stream being used inside a thread pool submition, like this:
ForkJoinPool.commonPool().submit(() -> {
mySet
.parallelStream()
... // do my fancy stuff and collect
})
Does just calling parallelStream() executes whatever comes next in multiple concurrent threads? Like in some pre-configured thread pool or something. Or do I have to create my threads and then use the parallel stream?