线程强制执行 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();
          }
      }
  }
}

 

posted on 2021-03-07 16:53  要给小八赚罐头钱  阅读(14)  评论(0)    收藏  举报