invokeall

Why should we call join after invokeAll method?

家住魔仙堡 提交于 2020-06-26 07:05:20
问题 I am trying to learn about the ForkJoinPool framework and came across the below example: public class ArrayCounter extends RecursiveTask<Integer> { int[] array; int threshold = 100_000; int start; int end; public ArrayCounter(int[] array, int start, int end) { this.array = array; this.start = start; this.end = end; } protected Integer compute() { if (end - start < threshold) { return computeDirectly(); } else { int middle = (end + start) / 2; ArrayCounter subTask1 = new ArrayCounter(array,