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();//线程插队
}
}
}
}
浙公网安备 33010602011771号