Reputation: 112
I know that we can use -Djava.util.concurrent.ForkJoinPool.common.parallelism to set the parallelism, but is there any upper limit to it?
Upvotes: 1
Views: 319
Reputation: 298123
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.
Upvotes: 2