Does AtomicReference.compareAndSet(old,new)
guarantee
old.field
wasn't change?- Or it just guarantees
old
wasn't reassign to a new object?
if 2 is true, does it mean AtomicReference
is useful only with immutable objects like String
? (Because in case of mutability of old
the old.field
changes are lost with a successfully compareAndSet
)