Detailed difference between Java8 ForkJoinPool and Executors.newWorkStealingPool?

前端 未结 3 527
既然无缘
既然无缘 2021-01-30 22:43

What is the low-level difference among using:

ForkJoinPool = new ForkJoinPool(X);

and

ExecutorService ex = Executors.neWorkStea         


        
3条回答
  •  Happy的楠姐
    2021-01-30 22:58

    It's only a abstraction for the Fork/Join Framework...

    /**
    * Creates a work-stealing thread pool using all
    * {@link Runtime#availableProcessors available processors}
    * as its target parallelism level.
    * @return the newly created thread pool
    * @see #newWorkStealingPool(int)
    * @since 1.8
    */
    public static ExecutorService newWorkStealingPool() {
        return new ForkJoinPool(Runtime.getRuntime().availableProcessors(),
                                ForkJoinPool.defaultForkJoinWorkerThreadFactory,
                                null, true);
    }
    

提交回复
热议问题