public class WaitThread implements Runnable {
public static void main(String[] args) throws InterruptedException {
Thread thread = new Thread(new WaitThread());
thread.start();
Thread.sleep(1);
thread.wait();
}
@Override
public void run() {
int num = 0;
while (num<999999){
num++;
System.out.println(“num=”+num);
}
}
}
我这么写 run方法还是会执行完毕的 我知道一般不会这么写,但不知道原理