Java Fork/Join 池:假设 fork join 池中的线程数量完全取决于 CPU 的基础数量是否正确?
Java Fork/Join Pool : Is it right to assume that number of threads in fork join pool depends entirely on underlying number of CPU's?
开发人员可以告诉 fork/join 池创建一定数量的线程吗?
如果是,那么是否保证池将创建那么多线程?
来源:https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html
A ForkJoinPool is constructed with a given target parallelism level; by default, equal to the number of available processors. The pool attempts to maintain enough active (or available) threads by dynamically adding, suspending, or resuming internal worker threads, even if some tasks are stalled waiting to join others
基本上,fork 连接池是 ThreadPool,它在 work-stealing 算法上工作。有 api 指定并行度(最大活动线程数 - (0-2^15-1))
指定并行度并不意味着池将在开始时创建那么多线程,但它会在工作提交到池时根据需要创建线程。
开发人员可以告诉 fork/join 池创建一定数量的线程吗? 如果是,那么是否保证池将创建那么多线程?
来源:https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.html
A ForkJoinPool is constructed with a given target parallelism level; by default, equal to the number of available processors. The pool attempts to maintain enough active (or available) threads by dynamically adding, suspending, or resuming internal worker threads, even if some tasks are stalled waiting to join others
基本上,fork 连接池是 ThreadPool,它在 work-stealing 算法上工作。有 api 指定并行度(最大活动线程数 - (0-2^15-1))
指定并行度并不意味着池将在开始时创建那么多线程,但它会在工作提交到池时根据需要创建线程。