I have three threads that are joined, i.e. the second thread executes after the first dies.
This is the code I have:
public class Main {
public static void main(String args[]) throws Exception {
final Thread thrdA = new Thread(() -> System.out.println("Message 1"));
final Thread thrdB = new Thread(() -> System.out.println("Message 2"));
final Thread thrdC = new Thread(() -> System.out.println("Message 3"));
thrdA.start();
thrdA.join();
thrdB.start();
thrdB.join();
thrdC.start();
thrdC.join();
}
}
How would I implement this functionality using ExecutorService
instead of three thread objects?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…