Atomically sets the field of the given object managed by this updater
to the given updated value if the current value
==
the
expected value. This method is guaranteed to be atomic with respect to
other calls to
compareAndSet
and
set
, but not
necessarily with respect to other changes in the field.
Returns:
true if successful.
Parameters:
-
obj - An object whose field to conditionally set
-
expect - the expected value
-
update - the new value
Throws:
-
ClassCastException - if {@code obj} is not an instance
of the class possessing the field established in the constructor.