其他分享
首页 > 其他分享> > 线程强制执行 join

线程强制执行 join

作者:互联网

线程强制执行 join

package com.Luoking.Thread;

public class ThreadJoin implements Runnable{

    //线程体方法
    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println("VIP正在办事。。。。请稍等"+i);
        }
    }


    public static void main(String[] args) throws InterruptedException {

        //主线程代码
        for (int i = 0; i < 200; i++) {
            if(i==20){
                //启动我们的线程
                ThreadJoin threadJoin = new ThreadJoin();
                Thread thread = new Thread(threadJoin);
                thread.start();
                thread.join();//线程插队
            }
            System.out.println("普通用户。。"+i);
        }

    }
}

标签:join,强制执行,Thread,ThreadJoin,thread,线程,public
来源: https://www.cnblogs.com/luoking/p/16208052.html