There is an array of N elements.

How many threads does arr.parallelStream() execute if the number of cores is 4 (let it be M )?

    1 answer 1

    Paralell stream uses ForkJoinPool , the number of streams in which is usually the Число ядер - 1 (However, it can be changed through the JVM launch argument) as well as the main stream. As a result, the number of threads is: ForkJoinPool.getCommonPoolParallelism() + 1 .