问题
I know that we can use -Djava.util.concurrent.ForkJoinPool.common.parallelism to set the parallelism, but is there any upper limit to it?
回答1:
By looking into the source code of ForkJoinPool, I find the definition of
MAX_CAP = 0x7fff; // max #workers - 1
which is enforced when using the constructor ForkJoinPool(int) by throwing an exception when you attempt to specify more. However, when using the system property, java.util.concurrent.ForkJoinPool.common.parallelism to configure the parallelism of the common pool, you can safely specify more (up to Integer.MAX_VALUE), it will be silently reduced to the supported maximum then.
来源:https://stackoverflow.com/questions/28694434/what-is-the-maximum-number-of-processes-that-can-be-used-in-parallel-stream