Name

AtomicIntegerArray

Synopsis

This class holds an array of int values. It provides threadsafe access to the array elements, treating each as if it was a volatile field, and defines atomic operations on them. The methods of this class are like those of AtomicInteger, except that each has an additional parameter that specifies the array index. Create an AtomicIntegerArray by specifying the desired array length or an actual int[ ] from which initial values can be copied.

java.util.concurrent.atomic.AtomicIntegerArray

Figure 16-99. java.util.concurrent.atomic.AtomicIntegerArray

public class AtomicIntegerArray implements Serializable {
// Public Constructors
     public AtomicIntegerArray(int[ ] array);  
     public AtomicIntegerArray(int length);  
// Public Instance Methods
     public final int addAndGet(int i, int delta);  
     public final boolean compareAndSet(int i, int expect, int update);  
     public final int decrementAndGet(int i);  
     public final int get(int i);  
     public final int getAndAdd(int i, int delta);  
     public final int getAndDecrement(int i);  
     public final int getAndIncrement(int i);  
     public final int getAndSet(int i, int newValue);  
     public final int incrementAndGet(int i);  
     public final int length( );  
     public final void set(int i, int newValue);  
     public final boolean weakCompareAndSet(int i, int expect, int update);  
// Public Methods Overriding Object
     public String toString( );  
}

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.