What is the maximum number of processes that can be used in parallel Stream

人盡茶涼 提交于 2020-01-03 02:43:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!