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

All Implemented Interfaces:
    java$io$Serializable, Serializable

A {@code long} value that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables. An {@code AtomicLong} is used in applications such as atomically incremented sequence numbers, and cannot be used as a replacement for a java.lang.Long . However, this class does extend {@code Number} to allow uniform access by tools and utilities that deal with numerically-based classes.
Field Summary
static final  boolean VM_SUPPORTS_LONG_CAS    Records whether the underlying JVM supports lockless compareAndSwap for longs. While the Unsafe.compareAndSwapLong method works in either case, some constructions should be handled at Java level to avoid locking user-visible locks. 
Constructor:
 public AtomicLong() 
 public AtomicLong(long initialValue) 
Method from java.util.concurrent.atomic.AtomicLong Summary:
addAndGet,   compareAndSet,   decrementAndGet,   doubleValue,   floatValue,   get,   getAndAdd,   getAndDecrement,   getAndIncrement,   getAndSet,   incrementAndGet,   intValue,   lazySet,   longValue,   set,   toString,   weakCompareAndSet
Methods from java.lang.Number:
byteValue,   doubleValue,   floatValue,   intValue,   longValue,   shortValue
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.concurrent.atomic.AtomicLong Detail:
 public final long addAndGet(long delta) 
    Atomically adds the given value to the current value.
 public final boolean compareAndSet(long expect,
    long update) 
    Atomically sets the value to the given updated value if the current value {@code ==} the expected value.
 public final long decrementAndGet() 
    Atomically decrements by one the current value.
 public double doubleValue() 
 public float floatValue() 
 public final long get() 
    Gets the current value.
 public final long getAndAdd(long delta) 
    Atomically adds the given value to the current value.
 public final long getAndDecrement() 
    Atomically decrements by one the current value.
 public final long getAndIncrement() 
    Atomically increments by one the current value.
 public final long getAndSet(long newValue) 
    Atomically sets to the given value and returns the old value.
 public final long incrementAndGet() 
    Atomically increments by one the current value.
 public int intValue() 
 public final  void lazySet(long newValue) 
    Eventually sets to the given value.
 public long longValue() 
 public final  void set(long newValue) 
    Sets to the given value.
 public String toString() 
    Returns the String representation of the current value.
 public final boolean weakCompareAndSet(long expect,
    long 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}.