public class AtomicReference
extends java.lang.Object
implements java.io.Serializable
edu.emory.mathcs.backport.java.util.concurrent.atomic
package specification for description
of the properties of atomic variables.Constructor and Description |
---|
AtomicReference()
Creates a new AtomicReference with null initial value.
|
AtomicReference(java.lang.Object initialValue)
Creates a new AtomicReference with the given initial value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
compareAndSet(java.lang.Object expect,
java.lang.Object update)
Atomically sets the value to the given updated value
if the current value
== the expected value. |
java.lang.Object |
get()
Gets the current value.
|
java.lang.Object |
getAndSet(java.lang.Object newValue)
Atomically sets to the given value and returns the old value.
|
void |
lazySet(java.lang.Object newValue)
Eventually sets to the given value.
|
void |
set(java.lang.Object newValue)
Sets to the given value.
|
java.lang.String |
toString()
Returns the String representation of the current value.
|
boolean |
weakCompareAndSet(java.lang.Object expect,
java.lang.Object update)
Atomically sets the value to the given updated value
if the current value
== the expected value. |
public AtomicReference(java.lang.Object initialValue)
initialValue
- the initial valuepublic AtomicReference()
public final java.lang.Object get()
public final void set(java.lang.Object newValue)
newValue
- the new valuepublic final void lazySet(java.lang.Object newValue)
newValue
- the new valuepublic final boolean compareAndSet(java.lang.Object expect, java.lang.Object update)
==
the expected value.expect
- the expected valueupdate
- the new valuepublic final boolean weakCompareAndSet(java.lang.Object expect, java.lang.Object update)
==
the expected value.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to compareAndSet
.
expect
- the expected valueupdate
- the new valuepublic final java.lang.Object getAndSet(java.lang.Object newValue)
newValue
- the new valuepublic java.lang.String toString()
toString
in class java.lang.Object