/**
* 控制线程的执行循序 T1 -> T2 -> T3
* join实现
*/
public static void join(){
Thread t1 = new Thread(() -> {
System.out.println("hello my is T1!");
});
Thread t2 = new Thread(() -> {
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("hello my is T2!");
});
Thread t3 = new Thread(() -> {
try {
t2.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("hello my is T3!");
});
t3.start();
t2.start();
t1.start();
}