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,266
  • 11
  • 41
  • 64

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
  • 310,138
  • 72
  • 642
  • 762