线程状态--强制执行

package state;

public class TestJoin 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 {
        TestJoin testJoin = new TestJoin();
        Thread thread = new Thread(testJoin);
        thread.start();

        for (int i = 0; i < 500; i++) {
            if(i==100){
                thread.join();
            }
            System.out.println("main线程"+i++);
        }
    }
}
posted @ 2023-03-10 20:23  北极有熊ovo  阅读(21)  评论(0)    收藏  举报