日期:2014-05-20 浏览次数:20927 次
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;
}
}