parallelStream()提交给ThreadPool vs ForkJoinPool?

时间:2018-05-03 15:27:51

标签: java

有很多地方解释为什么你通常应该使用带有包含的ForkJoinPool的parallelStream()。但是,您是否必须使用ForkJoinPool,还是可以使用任何ExecutorService?

ForkJoinPool forkJoinPool = new ForkJoinPool(4);
    forkJoinPool.submit(
      () -> aList.parallelStream().forEach(some parallel activity));

VS

ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
    cachedThreadPool.submit(
      () -> aList.parallelStream().forEach(some parallel activity));

0 个答案:

没有答案