62,621
社区成员
发帖
与我相关
我的任务
分享public class Test{
private static boolean ready;
private static int number;
private static class ReaderThread extends Thread
{
public void run()
{
while(!ready)
{
Thread.yield();
}
System.out.println(number);
}
}
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
new ReaderThread().start();
Thread.sleep(1000);
number = 42;
ready = true;
}
}