| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Integer one = …;
AtomicReference ai = new AtomicReference(one);
Based on 87 examples
public class AtomicReference extends Object implements Serializable
An object reference that may be updated atomically. See the {@link java.util.concurrent.atomic} package specification for description of the properties of atomic variables.
Constructor Summary | |
---|---|
Creates a new AtomicReference with null initial value. |
|
AtomicReference(Object initialValue) Creates a new AtomicReference with the given initial value. |
Method Summary | |
---|---|
boolean |
compareAndSet(Object expect, Object update) Atomically sets the value to the given updated value if the current value the expected value. |
Object |
get() Gets the current value. |
Object |
Atomically sets to the given value and returns the old value. |
void |
Eventually sets to the given value. |
void |
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 the expected value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AtomicReference()
public AtomicReference(Object initialValue)
initialValue
- the initial valueMethod Detail |
---|
public final boolean compareAndSet(Object expect, Object update)
expect
- the expected valueupdate
- the new valuepublic final Object get()
public final Object getAndSet(Object newValue)
newValue
- the new valuepublic final void lazySet(Object newValue)
newValue
- the new valuepublic final void set(Object newValue)
newValue
- the new valuepublic String toString()
toString
in class Object
public final boolean weakCompareAndSet(Object expect, Object update)
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}.
expect
- the expected valueupdate
- the new value
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |