10、线程强制执行jion

10、线程强制执行jion

 

package com.testthread1;

public class TestJion  implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("线程VIP");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        //启动线程
        TestJion testJion = new TestJion();
        Thread thread = new Thread(testJion);
        thread.start();

        //主线程
        for (int i = 0; i < 100; i++) {
            System.out.println("主线程:"+thread.getName());
            if (i==50){
                thread.join();//线程插队
            }
        }

    }
}

  

 

posted @ 2022-07-17 10:29  颓废且努力奋斗的人  阅读(32)  评论(0)    收藏  举报