import java.util.concurrent.TimeUnit;
public class test1 {
private static boolean ready;
private static int num;
private static class NoVisiu implements Runnable{
@Override
public void run() {
while(!ready){
System.out.println(num);
}
System.out.println(num);
}
}
public static void main(String[] args) throws InterruptedException {
Thread t=new Thread(new NoVisiu());
t.start();
TimeUnit.SECONDS.sleep(1);
num=42;
ready=true;
TimeUnit.SECONDS.sleep(1);
}
}
启动server模式后,按道理说会一直执行 。但是最终会输出42结束。
server模式是怎么启动的?