AtomicReference.compareAndSet Oversight?

Vitaly Davidovich vitalyd at gmail.com
Tue Nov 12 14:12:16 UTC 2013


This would have to devolve into a TTAS implementation in order to avoid
calling the supplier in cases where AR != expected.  Otherwise, hardware
needs the reference for the CAS.  TTAS isn't that common, I think.

Sent from my phone
On Nov 12, 2013 8:51 AM, "Gernot Neppert" <mcnepp02 at googlemail.com> wrote:

> While testing the methods added to the "Atomic" classes for Java 8,
> I was puzzled that I couldn't find the one method that I've been missing
> most in AtomicReference:
>
> boolean compareAndSet(V expect, Supplier<? extends V> supplier);
>
> Obviously, this would help implement a very efficient atomic
> "create-if-not-present" compound operation.
> Was it a deliberate decision to leave that one out?
>



More information about the core-libs-dev mailing list