[concurrency-interest] Volatile stores in constructors, disallowed to see the default value

Martin Buchholz martinrb at google.com
Thu Nov 28 18:48:44 EST 2013

On Wed, Nov 27, 2013 at 11:26 AM, Doug Lea <dl at cs.oswego.edu> wrote:

> Right. To summarize:
> * Programmers do not expect that even though final fields are specifically
> publication-safe, volatile fields are not always so.
Many programmers intuitively expect *all* fields assigned in constructors
to be publication-safe....

> * For various implementation reasons, JVMs arrange that
> volatile fields are publication safe anyway, at least in
> cases we know about.
... and at least on x86 with current JVMs, naive programmers are right -
*all* fields are in practice publication-safe.
... and I believe even some JDK classes depend on this being true ...

Which suggests we could actually expand final field guarantees to all
fields in the spec.  What's the actual expected loss of performance on
current hardware?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20131128/b48b7808/attachment-0001.html>

More information about the Concurrency-interest mailing list