Commit 7509ba98 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Update first thread test drive to use the executor service instead....

[Ch15] Update first thread test drive to use the executor service instead. It's generally fairly consistent in its order, but at least it prints stuff out "out of order"
parent 75c79cd4
Loading
Loading
Loading
Loading
+14 −0
Changes for src/main/java/ch15/ExecutorsTestDrive.java: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
package ch15;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorsTestDrive {
  public static void main(String[] args) {
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.submit(() -> System.out.println("top o’ the stack"));
    System.out.println("back in main");

    executor.shutdown();
  }
}
 No newline at end of file
+0 −9
Changes for src/main/java/ch15/ThreadTestDrive.java: 0 added lines, 9 removed lines.
Original line number Diff line number Diff line
package ch15;

public class ThreadTestDrive {
  public static void main(String[] args) {
    Thread myThread = new Thread(() -> System.out.println("top o’ the stack"));
    myThread.start();
    System.out.println("back in main");
  }
}
 No newline at end of file