java.util.concurrent.atomic
Class AtomicLongArray

public class AtomicLongArray
implements Serializable
A long 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
AtomicLongArray( int length )
Creates a new AtomicLongArray of given length.
AtomicLongArray( long [] array )
Creates a new AtomicLongArray with the same length as, and all elements copied from, the given array.
Method Summary
long addAndGet( int i, long delta )
Atomically adds the given value to the element at index i .
final boolean compareAndSet( int i, long expect, long update )
Atomically sets the value to the given updated value if the current value == the expected value.
final long decrementAndGet( int i )
Atomically decrements by one the element at index i .
final long get( int i )
Gets the current value at position i .
final long getAndAdd( int i, long delta )
Atomically adds the given value to the element at index i .
final long getAndDecrement( int i )
Atomically decrements by one the element at index i .
final long getAndIncrement( int i )
Atomically increments by one the element at index i .
final long getAndSet( int i, long newValue )
Atomically sets the element at position i to the given value and returns the old value.
final long incrementAndGet( int i )
Atomically increments by one the element at index i .
final void lazySet( int i, long 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, long 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, long expect, long update )
Atomically sets the value to the given updated value if the current value == the expected value.
AtomicLongArray
public AtomicLongArray ( int length )
Creates a new AtomicLongArray of given length.
Parameters
TypeNameDescription
int length the length of the array
Wiki javadoc Use textile entry format.
Add your comments here.
AtomicLongArray
public AtomicLongArray ( long [] array )
Creates a new AtomicLongArray with the same length as, and all elements copied from, the given array.
Parameters
TypeNameDescription
long[] array the array to copy elements from
Wiki javadoc Use textile entry format.
Add your comments here.
addAndGet
public long addAndGet ( int i, long delta )
Atomically adds the given value to the element at index i .
Parameters
TypeNameDescription
int i the index
long delta the value to add
Wiki javadoc Use textile entry format.
Add your comments here.
compareAndSet
public final boolean compareAndSet ( int i, long expect, long update )
Atomically sets the value to the given updated value if the current value == the expected value.
Parameters
TypeNameDescription
int i the index
long expect the expected value
long update the new value
Wiki javadoc Use textile entry format.
Add your comments here.
decrementAndGet
public final long 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 long 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 long getAndAdd ( int i, long delta )
Atomically adds the given value to the element at index i .
Parameters
TypeNameDescription
int i the index
long delta the value to add
Wiki javadoc Use textile entry format.
Add your comments here.
getAndDecrement
public final long 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 long 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 long getAndSet ( int i, long newValue )
Atomically sets the element at position i to the given value and returns the old value.
Parameters
TypeNameDescription
int i the index
long newValue the new value
Wiki javadoc Use textile entry format.
Add your comments here.
incrementAndGet
public final long 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, long newValue )
Eventually sets the element at position i to the given value.
Since: 1.6
Parameters
TypeNameDescription
int i the index
long 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, long newValue )
Sets the element at position i to the given value.
Parameters
TypeNameDescription
int i the index
long 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, long expect, long update )
Atomically sets the value 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
long expect the expected value
long update the new value
Wiki javadoc Use textile entry format.
Add your comments here.