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

Method main

concurrent/QuittingTasks.java:12–23  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

10public class QuittingTasks {
11 public static final int COUNT = 150;
12 public static void main(String[] args) {
13 ExecutorService es =
14 Executors.newCachedThreadPool();
15 List<QuittableTask> tasks =
16 IntStream.range(1, COUNT)
17 .mapToObj(QuittableTask::new)
18 .peek(qt -> es.execute(qt))
19 .collect(Collectors.toList());
20 new Nap(1);
21 tasks.forEach(QuittableTask::quit);
22 es.shutdown();
23 }
24}
25/* Output:
2611 23 20 12 24 16 19 15 35 147 32 27 7 4 28 31 8 83 3 1

Callers

nothing calls this directly

Calls 3

peekMethod · 0.80
rangeMethod · 0.80
executeMethod · 0.65

Tested by

no test coverage detected