Lew wrote:
* If an action x synchronizes-with a following action y, then we
also have hb(x, y).
* If hb(x, y) and hb(y, z), then hb(x, z).
The relation /happens-before/ holds for variables other than the
'volatile' due to that last rule, transitivity.
I was reading the line before "if an action x synchronizes-with a
following action y" to apply only to the volatile field. So I assumed
that the happens-before relationship held only for that field also.
Unfortunately I assumed incorrectly.
I re-read the section in JCiP that Knute quoted, and you and he are both
correct: according to Goetz, the volatile variable works just like a
lock with respect to making writes visible to other threads.
I must have read that the first time I read through JSiP, but either I
didn't get it, or it didn't stick in my head. Thanks to both of you for
pointing out this important feature of Java.
level features. Since java.util.concurrent appeared, I've started seeing
wait-notify as a bit clunky and low level.
going to terminate at the end of the array update phase. If not, I might
use a CountDownLatch.