Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.emory.mathcs.backport.java.util.concurrent.atomic
Class AtomicReference

    java.lang.Object
      edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicReference

All Implemented Interfaces:
  java.io.Serializable

public class AtomicReference
extends java.lang.Object
implements java.io.Serializable

An object reference that may be updated atomically. See the `edu.emory.mathcs.backport.java.util.concurrent.atomic` package specification for description of the properties of atomic variables.

Since:
  1.5
Author:
  Doug Lea
See Also:
  Serialized Form

Constructor Summary
`AtomicReference()` Creates a new AtomicReference with null initial value.
`AtomicReference(java.lang.Object initialValue)` Creates a new AtomicReference with the given initial value.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### AtomicReference

    public AtomicReference(java.lang.Object initialValue)

  Creates a new AtomicReference with the given initial value.

Parameters:
  `initialValue` - the initial value

### AtomicReference

    public AtomicReference()

  Creates a new AtomicReference with null initial value.

Method Detail

### get

    public final java.lang.Object get()

  Gets the current value.

  Returns:
    the current value

### set

    public final void set(java.lang.Object newValue)

  Sets to the given value.

  Parameters:
    `newValue` - the new value

### lazySet

    public final void lazySet(java.lang.Object newValue)

  Eventually sets to the given value.

  Parameters:
    `newValue` - the new value
  Since:
    1.6

### compareAndSet

    public final 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.

  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.

### weakCompareAndSet

    public final 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. May fail spuriously.

  Parameters:
    `expect` - the expected value
    `update` - the new value
  Returns:
    true if successful.

### getAndSet

    public final java.lang.Object getAndSet(java.lang.Object newValue)

  Atomically sets to the given value and returns the old value.

  Parameters:
    `newValue` - the new value
  Returns:
    the previous value

### toString

    public java.lang.String toString()

  Returns the String representation of the current value.

  Returns:
    the String representation of the current value.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD