MCPcopy Create free account
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

concurrent/CountingStream.java:11–18  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

9
10public class CountingStream {
11 public static void main(String[] args) {
12 System.out.println(
13 IntStream.range(0, 10)
14 .parallel()
15 .mapToObj(CountingTask::new)
16 .map(ct -> ct.call())
17 .reduce(0, Integer::sum));
18 }
19}
20/* Output:
211 ForkJoinPool.commonPool-worker-3 100

Callers

nothing calls this directly

Calls 2

rangeMethod · 0.80
callMethod · 0.65

Tested by

no test coverage detected