[concurrency-interest] AtomicReference.updateAndGet() mandatory updating

Andrew Haley aph at redhat.com
Thu May 25 06:16:30 EDT 2017

On 25/05/17 09:16, Gil Tene wrote:
>> On May 25, 2017, at 12:35 AM, Alex Otenko <oleksandr.otenko at gmail.com> wrote:
>> This is a bad idea.
>> Now there is no guarantee that the synchronizes-with edge exists.
> The current Java 9 specification (in the JavaDoc) of AtomicReference.updateAndGet() doesn't say there is such an edge (the Java 8 one did, but the current Java 9 one doesn't). So this is valid with the current spec'ed behavior. The spec is probably wrong and should be changed to document the expected memory semantics in any case, and depending on what those are, the suggested optimization will either be 
ok or wrong to do.

Ah, I see:

"compareAndSet and all other read-and-update operations such as getAndIncrement have the memory effects of both reading and writing volatile variables. "
seems to have gone.  That's a breaking spec change if there's nothing anywhere else.


More information about the Concurrency-interest mailing list