[concurrency-interest] 8145539: (coll) AbstractMap.keySet and .values should not be volatile

Vitaly Davidovich vitalyd at gmail.com
Tue Apr 26 15:16:15 EDT 2016

Yes, I believe JVMs are not allowed to introduce phantom reads or writes.
In other words, reading a plain field into a local (and only using the
local) in java means it will not be re-read, whereas no such guarantee
exists in C/C++.  Relatedly, that blog shows a case where gcc and clang
read and write, back-to-back(!), a field to memory -- that is also not
allowed in conforming JVMs, AFAIK.

On Tue, Apr 26, 2016 at 3:12 PM, Justin Sampson <jsampson at guidewire.com>

> Vitaly Davidovich wrote:
> > The problem is compilers can do weird things on the assumption of
> > data race free code. If you haven't seen
> >
> https://software.intel.com/en-us/blogs/2013/01/06/benign-data-races-what-could-possibly-go-wrong
> > I recommend reading it. It's in the context of C/C++/Go but the
> > general point stands.
> Interesting -- that article actually seems to describe cases of
> thin-air reads due to the compiler reusing memory locations, which
> is impossible in Java even for racy code, right?
> Thanks,
> Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20160426/47ccbab6/attachment.html>

More information about the Concurrency-interest mailing list