Instruction reordering & happens-before relationship [duplicate]
The key point of the program order rule is: in a thread. Imagine this simple program (all variables initially 0): T1: x = 5; y = 6; T2: if (y == 6) System.out.println(x); From T1’s perspective, an execution must be consistent with y being assigned after x (program order). However from T2’s perspective this does … Read more