p14线程强制执行join
package kuang.com.demo;
//不建议使用,会导致阻塞
public class Testjoin implements Runnable{
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println("VIP来啦"+i);
}
}
public static void main(String[] args) throws InterruptedException {
//启动vip线程
Testjoin testjoin = new Testjoin();
Thread thread = new Thread(testjoin);
thread.start();
//主线程
for (int i = 0; i < 1000; i++) {
if(i == 200){
thread.join();//插队
}
System.out.println("main"+i);
}
}
}