An object reference that may be updated atomically. See the
package specification for description
of the properties of atomic variables.
| Method from java.util.concurrent.atomic.AtomicReference Detail: |
public final boolean compareAndSet(V expect,
V update) {
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
}
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value. |
public final V get() {
return value;
}
|
public final V getAndSet(V newValue) {
while (true) {
V x = get();
if (compareAndSet(x, newValue))
return x;
}
}
Atomically sets to the given value and returns the old value. |
public final void lazySet(V newValue) {
unsafe.putOrderedObject(this, valueOffset, newValue);
}
Eventually sets to the given value. |
public final void set(V newValue) {
value = newValue;
}
|
public String toString() {
return String.valueOf(get());
}
Returns the String representation of the current value. |
public final boolean weakCompareAndSet(V expect,
V update) {
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
}
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to {@code compareAndSet}. |