线程强制执行 join
public class TestJoin implements Runnable{
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println("靠边!俺来了!"+i);
}
}
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new TestJoin());
thread.start();
for (int num = 0; num < 200; num++) {
System.out.println("排队吃饭饭"+num);
if (num==100){
thread.join();
}
}
}
}