Commit e7f01501 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Version of the RunThreads code for the book

parent bae326e2
Loading
Loading
Loading
Loading
+4 −4
Changes for src/main/java/ch15/RunThreads.java: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -7,15 +7,15 @@ public class RunThreads {

  public static void main(String[] args) {
    ExecutorService threadPool = Executors.newFixedThreadPool(2);
    threadPool.execute(() -> run("Job 1"));
    threadPool.execute(() -> run("Job 2"));
    threadPool.execute(() -> runJob("Job 1"));
    threadPool.execute(() -> runJob("Job 2"));
    threadPool.shutdown();
  }

  public static void run(String jobName) {
  public static void runJob(String jobName) {
    for (int i = 0; i < 25; i++) {
      String threadName = Thread.currentThread().getName();
      System.out.println(jobName + " is running on thread " + threadName);
      System.out.println(jobName + " is running on " + threadName);
    }
  }
}
 No newline at end of file