[jmm-dev] Atomic references

Doug Lea dl at cs.oswego.edu
Sun Feb 9 11:57:36 PST 2014


On 02/09/2014 10:33 AM, Ludwig, Mark wrote:
> This is probably in the category of "picking a nit," but I have yet to find
> any statement that shared Java variables that are object references are
> atomic.

Yes, they must be. The statement is hiding in JLS sec 17.7

"Writes to and reads of references are always atomic, regardless of whether they 
are implemented as 32-bit or 64-bit values."

http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.7

(Curiously, there is no direct statement that ints, shorts, chars,
or bytes are atomic. This probably needs fixing.)

-Doug



More information about the jmm-dev mailing list