From: Lew on
Tom Anderson wrote:
> All i'll [sic] add is that what volatile does is somewhat subtle, tying in to
> the rest of the memory model, so there isn't a simple way to isolate it
> in explanation - but the memory model section in the JLS is really very
> good, and people ought to read it. I'd honestly suggest reading that
> rather than reading someone else's interpretation of it. Perhaps the
> most useful format would be an annotated copy of the JLS text on this
> matter?

Excellent suggestion. Postgres, for example, has two version of its
docs online - a "static" version with just the official text, and a
"dynamic" version where users (we) can post and read comments.

--
Lew
From: Roedy Green on
On Sat, 13 Feb 2010 12:41:28 +0000, Tom Anderson
<twic(a)urchin.earth.li> wrote, quoted or indirectly quoted someone who
said :

>All i'll add is that what volatile does is somewhat subtle, tying in to
>the rest of the memory model, so there isn't a simple way to isolate it in
>explanation - but the memory model section in the JLS is really very
>good, and people ought to read it. I'd honestly suggest reading that
>rather than reading someone else's interpretation of it.

see http://mindprod.com/jgloss/volatile.html#LEARNINGMORE

I have added your observation.
--
Roedy Green Canadian Mind Products
http://mindprod.com

Every compilable program in a sense works. The problem is with your unrealistic expections on what it will do.
From: Roedy Green on
On Sat, 13 Feb 2010 09:52:49 -0500, Lew <lew(a)lewscanon.com> wrote,
quoted or indirectly quoted someone who said :

>
>Excellent suggestion. Postgres, for example, has two version of its
>docs online - a "static" version with just the official text, and a
>"dynamic" version where users (we) can post and read comments.


What I would like to see a way of combining the official text with
commentary, in a structured way so that you can hide and reveal extra
information. The same mechanism would let you view a text in beginner
mode where all the fine points and difficult sections are suppressed,
or in expert mode, where all the easy stuff is suppressed.

The problem with ordinary commentaries is they go stale and thus
mislead, or they can be simply wrong or oversimplified.

The Wiki model seems to work well, except that it tends to balloon
with trivia.

See http://mindprod.com/jgloss/author.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

Every compilable program in a sense works. The problem is with your unrealistic expections on what it will do.
From: Arne Vajhøj on
On 12-02-2010 11:36, Eric Sosman wrote:
> Your recollection about 64-bit accesses is correct, but it's
> a remembrance of things past: Early Java allowed non-atomicity as
> a concession to machines that lacked 64-bit atomic operations.
> But 64-bit-capable machines are now the norm instead of the
> exception, and the rules have been tightened up. (I think this
> may have happened as part of the effort to nail down Java's memory
> model, which was pretty loosey-goosey in the early days.)

I believe that current JLS still does not guarantee
atomicity of reading/writing long and double.

And even though most CPU's today support 64 bit, then
a lot of them are running in 32 bit mode.

Arne
From: Peter Duniho on
Arne Vajh�j wrote:
> I believe that current JLS still does not guarantee
> atomicity of reading/writing long and double.

Those being primitive types, it does. Lew even described the relevant
"volatile" rule in his earlier reply:

Lew wrote:
> [...]
> - Reads from and writes to 'x' are atomic, whether that variable
> represents any primitive including 'long' or 'double', or a reference.

Pete