Detailed difference between Java8 ForkJoinPool and Executors.newWorkStealingPool?

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

What is the low-level difference among using:

ForkJoinPool = new ForkJoinPool(X);

and

ExecutorService ex = Executors.neWorkStea         


        
3条回答
  •  不要未来只要你来
    2021-01-30 22:59

    newWorkStealingPool is a higher level of abstraction for ForkJoinPool.

    If you look at the Oracle jvm implementation, it's simply a preconfigured ForkJoinPool:

    public static ExecutorService newWorkStealingPool() {
        return new ForkJoinPool(Runtime.getRuntime().availableProcessors(),
                                ForkJoinPool.defaultForkJoinWorkerThreadFactory,
                                null, 
                                true);
    }
    

    Unfortunately looking at implementations isn't a proper way for understanding purpose of a class though.

    Also credit to: https://dzone.com/articles/diving-into-java-8s-newworkstealingpools

提交回复
热议问题