[concurrency-interest] Curious: How Java Memory Model is satisfied in JSR166 locks?
matthias at mernst.org
Tue Aug 21 09:36:38 EDT 2007
On 8/21/07, Compl Yue Still <complystill at gmail.com> wrote:
> do you imply that accessing a volatile variable causes Hotspot to
> synchronize the thread's working memory with main memory? I'm doubting
> coz I havn't noticed this requirement in JLS..
Sorry for the short reply, esp. since I missed mentioning the magic
entailed in the Unsafe class as explained by Osvaldo.
To answer your question: this is new since the JSR133 revision of the
memory model (JLS v3;
In layman's terms, yes, access to volatile fields also affects the
visibility of values read from/written to ordinary fields after/before
that. It follows from "program order" in combination with "A write to
a volatile field (§126.96.36.199) happens-before every subsequent read of
Before v3, this was not the case and it is one of the, if not the
major achievement of 133.
More information about the Concurrency-interest