Save This Page
Home » openjdk-7 » java » util » concurrent » atomic » [javadoc | source]
java.util.concurrent.atomic
public class: AtomicReference [javadoc | source]
java.lang.Object
   java.util.concurrent.atomic.AtomicReference

All Implemented Interfaces:
    java$io$Serializable

Direct Known Subclasses:
    Node, Slot

An object reference that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables.
Constructor:
 public AtomicReference() 
 public AtomicReference(V initialValue) 
Method from java.util.concurrent.atomic.AtomicReference Summary:
compareAndSet,   get,   getAndSet,   lazySet,   set,   toString,   weakCompareAndSet
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.concurrent.atomic.AtomicReference Detail:
 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.
 public final V get() 
    Gets the current value.
 public final V getAndSet(V newValue) 
    Atomically sets to the given value and returns the old value.
 public final  void lazySet(V newValue) 
    Eventually sets to the given value.
 public final  void set(V newValue) 
    Sets to the given value.
 public String toString() 
    Returns the String representation of the current value.
 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}.