Methods Summary |
---|
public final boolean | compareAndSet(V expect, V update)Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
|
public final V | get()Gets the current value.
return value;
|
public final V | getAndSet(V newValue)Atomically sets to the given value and returns the old value.
while (true) {
V x = get();
if (compareAndSet(x, newValue))
return x;
}
|
public final void | lazySet(V newValue)Eventually sets to the given value.
unsafe.putOrderedObject(this, valueOffset, newValue);
|
public final void | set(V newValue)Sets to the given value.
value = newValue;
|
public java.lang.String | toString()Returns the String representation of the current value.
return String.valueOf(get());
|
public final boolean | weakCompareAndSet(V expect, V 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}.
return unsafe.compareAndSwapObject(this, valueOffset, expect, update);
|