java.util.concurrent.atomic
Class AtomicIntegerArray

public class AtomicIntegerArray
implements Serializable
An int array in which elements may be updated atomically. See the java.util.concurrent.atomic package specification for description of the properties of atomic variables.
Since1.5
VersionNot specified.
AuthorDoug Lea
Wiki javadoc Use textile entry format.
Add your comments here.
Constructor Summary
AtomicIntegerArray( int length )
Creates a new AtomicIntegerArray of given length.
AtomicIntegerArray( int [] array )
Creates a new AtomicIntegerArray with the same length as, and all elements copied from, the given array.
Method Summary
final int addAndGet( int i, int delta )
Atomically adds the given value to the element at index i .
final boolean compareAndSet( int i, int expect, int update )
Atomically sets the element at position i to the given updated value if the current value == the expected value.
final int decrementAndGet( int i )
Atomically decrements by one the element at index i .
final int get( int i )
Gets the current value at position i .
final int getAndAdd( int i, int delta )
Atomically adds the given value to the element at index i .
final int getAndDecrement( int i )
Atomically decrements by one the element at index i .
final int getAndIncrement( int i )
Atomically increments by one the element at index i .
final int getAndSet( int i, int newValue )
Atomically sets the element at position i to the given value and returns the old value.
final int incrementAndGet( int i )
Atomically increments by one the element at index i .
final void lazySet( int i, int newValue )
Eventually sets the element at position i to the given value.
final int length()
Returns the length of the array.
final void set( int i, int newValue )
Sets the element at position i to the given value.
String toString()
Returns the String representation of the current values of array.
final boolean weakCompareAndSet( int i, int expect, int update )
Atomically sets the element at position i to the given updated value if the current value == the expected value.
AtomicIntegerArray
public AtomicIntegerArray ( int length )
Creates a new AtomicIntegerArray of given length.
Parameters
TypeNameDescription
int length the length of the array
Wiki javadoc Use textile entry format.
Add your comments here.
AtomicIntegerArray
public AtomicIntegerArray ( int [] array )
Creates a new AtomicIntegerArray with the same length as, and all elements copied from, the given array.
Parameters
TypeNameDescription
int[] array the array to copy elements from
Wiki javadoc Use textile entry format.
Add your comments here.
addAndGet
public final int addAndGet ( int i, int delta )
Atomically adds the given value to the element at index i .
Parameters
TypeNameDescription
int i the index
int delta the value to add
Wiki javadoc Use textile entry format.
Add your comments here.
compareAndSet
public final boolean compareAndSet ( int i, int expect, int update )
Atomically sets the element at position i to the given updated value if the current value == the expected value.
Parameters
TypeNameDescription
int i the index
int expect the expected value
int update the new value
Wiki javadoc Use textile entry format.
Add your comments here.
decrementAndGet
public final int decrementAndGet ( int i )
Atomically decrements by one the element at index i .
Parameters
TypeNameDescription
int i the index
Wiki javadoc Use textile entry format.
Add your comments here.
get
public final int get ( int i )
Gets the current value at position i .
Parameters
TypeNameDescription
int i the index
Wiki javadoc Use textile entry format.
Add your comments here.
getAndAdd
public final int getAndAdd ( int i, int delta )
Atomically adds the given value to the element at index i .
Parameters
TypeNameDescription
int i the index
int delta the value to add
Wiki javadoc Use textile entry format.
Add your comments here.
getAndDecrement
public final int getAndDecrement ( int i )
Atomically decrements by one the element at index i .
Parameters
TypeNameDescription
int i the index
Wiki javadoc Use textile entry format.
Add your comments here.
getAndIncrement
public final int getAndIncrement ( int i )
Atomically increments by one the element at index i .
Parameters
TypeNameDescription
int i the index
Wiki javadoc Use textile entry format.
Add your comments here.
getAndSet
public final int getAndSet ( int i, int newValue )
Atomically sets the element at position i to the given value and returns the old value.
Parameters
TypeNameDescription
int i the index
int newValue the new value
Wiki javadoc Use textile entry format.
Add your comments here.
incrementAndGet
public final int incrementAndGet ( int i )
Atomically increments by one the element at index i .
Parameters
TypeNameDescription
int i the index
Wiki javadoc Use textile entry format.
Add your comments here.
lazySet
public final void lazySet ( int i, int newValue )
Eventually sets the element at position i to the given value.
Since: 1.6
Parameters
TypeNameDescription
int i the index
int newValue the new value
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
length
public final int length ( )
Returns the length of the array.
Wiki javadoc Use textile entry format.
Add your comments here.
set
public final void set ( int i, int newValue )
Sets the element at position i to the given value.
Parameters
TypeNameDescription
int i the index
int newValue the new value
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
toString
public String toString ( )
Returns the String representation of the current values of array.
Overrides method in Object
Wiki javadoc Use textile entry format.
Add your comments here.
weakCompareAndSet
public final boolean weakCompareAndSet ( int i, int expect, int update )
Atomically sets the element at position i to the given updated value if the current value == the expected value.

May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet .

Parameters
TypeNameDescription
int i the index
int expect the expected value
int update the new value
Wiki javadoc Use textile entry format.
Add your comments here.