有很多地方解释为什么你通常应该使用带有包含的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));