An {@code int} array in which elements may be updated atomically.
See the
package
specification for description of the properties of atomic
variables.
| Method from java.util.concurrent.atomic.AtomicIntegerArray Detail: |
public final int addAndGet(int i,
int delta) {
while (true) {
int current = get(i);
int next = current + delta;
if (compareAndSet(i, current, next))
return next;
}
}
Atomically adds the given value to the element at index {@code i}. |
public final boolean compareAndSet(int i,
int expect,
int update) {
return unsafe.compareAndSwapInt(array, rawIndex(i),
expect, update);
}
Atomically sets the element at position {@code i} to the given
updated value if the current value {@code ==} the expected value. |
public final int decrementAndGet(int i) {
while (true) {
int current = get(i);
int next = current - 1;
if (compareAndSet(i, current, next))
return next;
}
}
Atomically decrements by one the element at index {@code i}. |
public final int get(int i) {
return unsafe.getIntVolatile(array, rawIndex(i));
}
Gets the current value at position {@code i}. |
public final int getAndAdd(int i,
int delta) {
while (true) {
int current = get(i);
int next = current + delta;
if (compareAndSet(i, current, next))
return current;
}
}
Atomically adds the given value to the element at index {@code i}. |
public final int getAndDecrement(int i) {
while (true) {
int current = get(i);
int next = current - 1;
if (compareAndSet(i, current, next))
return current;
}
}
Atomically decrements by one the element at index {@code i}. |
public final int getAndIncrement(int i) {
while (true) {
int current = get(i);
int next = current + 1;
if (compareAndSet(i, current, next))
return current;
}
}
Atomically increments by one the element at index {@code i}. |
public final int getAndSet(int i,
int newValue) {
while (true) {
int current = get(i);
if (compareAndSet(i, current, newValue))
return current;
}
}
Atomically sets the element at position {@code i} to the given
value and returns the old value. |
public final int incrementAndGet(int i) {
while (true) {
int current = get(i);
int next = current + 1;
if (compareAndSet(i, current, next))
return next;
}
}
Atomically increments by one the element at index {@code i}. |
public final void lazySet(int i,
int newValue) {
unsafe.putOrderedInt(array, rawIndex(i), newValue);
}
Eventually sets the element at position {@code i} to the given value. |
public final int length() {
return array.length;
}
Returns the length of the array. |
public final void set(int i,
int newValue) {
unsafe.putIntVolatile(array, rawIndex(i), newValue);
}
Sets the element at position {@code i} to the given value. |
public String toString() {
if (array.length > 0) // force volatile read
get(0);
return Arrays.toString(array);
}
Returns the String representation of the current values of array. |
public final boolean weakCompareAndSet(int i,
int expect,
int update) {
return compareAndSet(i, expect, update);
}
Atomically sets the element at position {@code i} 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}. |