edu.emory.mathcs.backport.java.util.concurrent.atomic
public class AtomicReference extends Object implements Serializable
Since: 1.5
Constructor Summary | |
---|---|
AtomicReference(Object initialValue)
Creates a new AtomicReference with the given initial value.
| |
AtomicReference()
Creates a new AtomicReference with null initial value. |
Method Summary | |
---|---|
boolean | compareAndSet(Object expect, Object update)
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value. |
Object | get()
Gets the current value.
|
Object | getAndSet(Object newValue)
Atomically sets to the given value and returns the old value.
|
void | lazySet(Object newValue)
Eventually sets to the given value.
|
void | set(Object newValue)
Sets to the given value.
|
String | toString()
Returns the String representation of the current value. |
boolean | weakCompareAndSet(Object expect, Object update)
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
|
Parameters: initialValue the initial value
Parameters: expect the expected value update the new value
Returns: true if successful. False return indicates that the actual value was not equal to the expected value.
Returns: the current value
Parameters: newValue the new value
Returns: the previous value
Parameters: newValue the new value
Since: 1.6
Parameters: newValue the new value
Returns: the String representation of the current value.
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}.
Parameters: expect the expected value update the new value
Returns: true if successful.