4

Java Concurrency in Practice says (in JMM chapter)
Volatile variable rule: a write to a volatile field happens before every subsequent read of that same field

My question is : A read to a volatile field happens before any/every subsequent write on that same field ??

lowLatency
  • 5,534
  • 12
  • 44
  • 70

1 Answers1

1

Theoretically it is a one way relationship. The exhaustive list of happens-before relationships is defined in the JLS #17.4.5 and only includes hb(volatile write, volatile read).

However it is likely that it is implemented both ways by the JVM (it is the case for hotspot).

assylias
  • 321,522
  • 82
  • 660
  • 783