其他分享
首页 > 其他分享> > 10、线程强制执行jion

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();//线程插队
            }
        }

    }
}

  

 

标签:10,TestJion,thread,int,System,线程,jion,public
来源: https://www.cnblogs.com/tfqfdr/p/16484803.html