public class Test3 {
private static boolean ready; private static int Number; private static class ReaderThread extends Thread {@Override
public void run() { if(!ready) { Thread.yield(); System.out.println(Number); } } public static void main(String[] args) { new ReaderThread().start(); Number = 42; ready = true; } }}在JVM跑的时候虚拟机会重新对代码进行排序 可能输出空也可能是42,甚至可能永远循环下去(这种成为重排序)