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

All Implemented Interfaces:
    java$io$Serializable, Serializable

An {@code int} value that may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables. An {@code AtomicInteger} is used in applications such as atomically incremented counters, and cannot be used as a replacement for an java.lang.Integer . However, this class does extend {@code Number} to allow uniform access by tools and utilities that deal with numerically-based classes.
Constructor:
 public AtomicInteger() 
 public AtomicInteger(int initialValue) 
Method from java.util.concurrent.atomic.AtomicInteger 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.AtomicInteger Detail:
 public final int addAndGet(int delta) 
    Atomically adds the given value to the current value.
 public final boolean compareAndSet(int expect,
    int update) 
    Atomically sets the value to the given updated value if the current value {@code ==} the expected value.
 public final int decrementAndGet() 
    Atomically decrements by one the current value.
 public double doubleValue() 
 public float floatValue() 
 public final int get() 
    Gets the current value.
 public final int getAndAdd(int delta) 
    Atomically adds the given value to the current value.
 public final int getAndDecrement() 
    Atomically decrements by one the current value.
 public final int getAndIncrement() 
    Atomically increments by one the current value.
 public final int getAndSet(int newValue) 
    Atomically sets to the given value and returns the old value.
 public final int incrementAndGet() 
    Atomically increments by one the current value.
 public int intValue() 
 public final  void lazySet(int newValue) 
    Eventually sets to the given value.
 public long longValue() 
 public final  void set(int newValue) 
    Sets to the given value.
 public String toString() 
    Returns the String representation of the current value.
 public final boolean weakCompareAndSet(int expect,
    int 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}.