【发布时间】:2015-11-09 06:29:59
【问题描述】:
我有三个线程连接在一起,即第二个线程在第一个线程死后执行。
这是我的代码:
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();
}
}
如何使用ExecutorService 而不是三个线程对象来实现此功能?
【问题讨论】:
标签: java multithreading concurrency