MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / main

Method main

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

Source from the content-addressed store, hash-verified

16 .noneMatch(i -> n % i == 0);
17 }
18 public static void main(String[] args)
19 throws IOException {
20 Timer timer = new Timer();
21 List<String> primes =
22 iterate(2, i -> i + 1)
23 .parallel() // [1]
24 .filter(ParallelPrime::isPrime)
25 .limit(COUNT)
26 .mapToObj(Long::toString)
27 .collect(Collectors.toList());
28 System.out.println(timer.duration());
29 Files.write(Paths.get("primes.txt"), primes,
30 StandardOpenOption.CREATE);
31 }
32}
33/* Output:
341635

Callers

nothing calls this directly

Calls 2

durationMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected