package cn.itcast_05;
/*
* public final void join():等待线程终止
*
* 是为了让某一个线程执行完毕,后再执行其他线程
*
*/
public class 线程控制之加入线程 {
public static void main(String[] args) {
//创建对象
MyThread my1 = new MyThread();
MyThread my2 = new MyThread();
MyThread my3 = new MyThread();
my1.setName("李渊");
my2.setName("李世民");
my3.setName("李元霸");
my1.start();
try {
my1.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
my2.start();
my3.start();
}
}
Java thread control to join the thread
Guess you like
Origin blog.csdn.net/kaszxc/article/details/108889694
Ranking