日期:2014-05-20 浏览次数:20708 次
public class Test { private static boolean b; private static int i = 1; public static void main(String[] args) throws InterruptedException { Thread thread = new Thread(new Runnable() { @Override public void run() { while (!b) { System.out.println(i); } } }); thread.start(); TimeUnit.SECONDS.sleep(1); b = true; i = 2; System.out.println(b); } }