日期:2014-05-20 浏览次数:20723 次
public class ThreadTest { private static boolean ready; private static int number; private static class ReaderThread extends Thread { /* (non-Javadoc) * @see java.lang.Thread#run() */ public void run() { while(!ready) { Thread.yield(); System.out.println(number); } } } /** * @param args */ public static void main(String[] args) { new ReaderThread().start(); number = 42; ready = false; } }