| |
|
| java.lang.Object java.util.concurrent.atomic.AtomicReference
AtomicReference | public class AtomicReference implements java.io.Serializable(Code) | | An object reference that may be updated atomically. See the
java.util.concurrent.atomic package specification for description
of the properties of atomic variables.
since: 1.5 author: Doug Lea< Parameters: V - > The type of object referred to by this reference |
Constructor Summary | |
public | AtomicReference(V initialValue) Creates a new AtomicReference with the given initial value. | public | AtomicReference() Creates a new AtomicReference with null initial value. |
Method Summary | |
final public boolean | compareAndSet(V expect, V update) Atomically sets the value to the given updated value
if the current value
== the expected value.
Parameters: expect - the expected value Parameters: update - the new value true if successful. | final public V | get() Gets the current value. | final public V | getAndSet(V newValue) Atomically sets to the given value and returns the old value. | final public void | lazySet(V newValue) Eventually sets to the given value. | final public void | set(V newValue) Sets to the given value. | public String | toString() Returns the String representation of the current value. | final public boolean | weakCompareAndSet(V expect, V update) Atomically sets the value to the given updated value
if the current value
== the expected value. |
AtomicReference | public AtomicReference(V initialValue)(Code) | | Creates a new AtomicReference with the given initial value.
Parameters: initialValue - the initial value |
AtomicReference | public AtomicReference()(Code) | | Creates a new AtomicReference with null initial value.
|
compareAndSet | final public boolean compareAndSet(V expect, V update)(Code) | | Atomically sets the value to the given updated value
if the current value
== the expected value.
Parameters: expect - the expected value Parameters: update - the new value true if successful. False return indicates thatthe actual value was not equal to the expected value. |
get | final public V get()(Code) | | Gets the current value.
the current value |
getAndSet | final public V getAndSet(V newValue)(Code) | | Atomically sets to the given value and returns the old value.
Parameters: newValue - the new value the previous value |
lazySet | final public void lazySet(V newValue)(Code) | | Eventually sets to the given value.
Parameters: newValue - the new value since: 1.6 |
set | final public void set(V newValue)(Code) | | Sets to the given value.
Parameters: newValue - the new value |
toString | public String toString()(Code) | | Returns the String representation of the current value.
the String representation of the current value. |
weakCompareAndSet | final public boolean weakCompareAndSet(V expect, V update)(Code) | | Atomically sets the value to the given updated value
if the current value
== the expected value.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to
compareAndSet .
Parameters: expect - the expected value Parameters: update - the new value true if successful. |
|
|
|