Is volatile read happens-before volatile write?
问题 I try to understand why this example is a correctly synchronized program: a - volatile Thread1: x=a Thread2: a=5 Because there are conflicting accesses (there is a write to and read of a) so in every sequential consistency execution must be happens-before relation between that accesses. Suppose one of sequential execution: 1. x=a 2. a=5 Is 1 happens-before 2, why? 回答1: No, a volatile read before (in synchronization order) a volatile write of the same variable does not necessarily happens