Skip to content

Commit

Permalink
ForkJoinTest
Browse files Browse the repository at this point in the history
  • Loading branch information
javahongxi committed Aug 11, 2019
1 parent f7d9449 commit 82b7d85
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -6,6 +6,7 @@
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.RecursiveAction;
import java.util.concurrent.CountedCompleter;
import java.util.stream.IntStream;

/**
* @author shenhongxi 2019/8/11
Expand Down Expand Up @@ -33,6 +34,11 @@ public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.print(array[i] + " ");
}

System.out.println();
IntStream.range(1, 10).forEach(e -> System.out.print(e + " "));
System.out.println();
IntStream.range(1, 10).parallel().forEach(e -> System.out.print(e + " "));
}

static class AccumulationTask extends RecursiveTask<Integer> {
Expand Down

0 comments on commit 82b7d85

Please sign in to comment.