Re: The D Programming Language
James Kanze wrote:
I get the feeling that Andrei is confusing atomic and
synchronized. Writes to pointers in Java are guaranteed to be
atomic; they're not "synchronized", neither in the usual sense,
nor in the Java language sense.
No, I just used synchronized in lieu of atomic (as the effect is the
same), as I clarified in a different post.
Of course, this means that other threads can see pointers to
objects which aren't yet constructed. But that's generally true
in Java, even without threads; just call a virtual function from
a base class constructor.
This is defined behavior - I'd agree not the best choice, but defined.
It's not worth discussing it further.
Worse, other threads can see pointers
to objects which haven't yet been zero initialized (or
initialized at all). That is, of course, the undefined behavior
that Java supposedly doesn't have. (I'm rather surprised that
Andrei doesn't recognize this. IIRC, he's written on the
problems of double checked locking in the past, and this problem
is related.)
My understanding is that previous implementations of Java did have the
threading issues you mention, and that the work on the Java memory model
made it impossible for a thread to see an uninitialized object. So
according to my understanding, your representation of the situation is
perfectly accurate... as of four years ago.
Andrei
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]