package thread02;
/**
* Join 合并线程(插队线程)
* @author
*
*/
public class TestJoin {
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(()->{
for(int i=0; i<100; i++) {
System.out.println("lambda....."+i);
}
});
t.start();
for(int i=1; i<=100; i++) {
if(i == 20){
t.join();//插队 main主线程被阻塞了
}
System.out.println("main...."+i);
}
}
}
多线程 线程状态 插队 (join)
最新推荐文章于 2024-06-19 21:11:55 发布