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

Method main

concurrent/SingleThreadExecutor.java:10–24  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

8
9public class SingleThreadExecutor {
10 public static void main(String[] args) {
11 ExecutorService exec =
12 Executors.newSingleThreadExecutor();
13 IntStream.range(0, 10)
14 .mapToObj(NapTask::new)
15 .forEach(exec::execute);
16 System.out.println("All tasks submitted");
17 exec.shutdown();
18 while(!exec.isTerminated()) {
19 System.out.println(
20 Thread.currentThread().getName() +
21 " awaiting termination");
22 new Nap(0.1);
23 }
24 }
25}
26/* Output:
27All tasks submitted

Callers

nothing calls this directly

Calls 1

rangeMethod · 0.80

Tested by

no test coverage detected