Methods Summary |
---|
public int | addAndGet(T obj, int delta)Atomically adds the given value to the current value of the field of
the given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current + delta;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract boolean | compareAndSet(T obj, int expect, int update)Atomically sets the field of the given object managed by this updater
to the given updated value if the current value {@code ==} the
expected value. This method is guaranteed to be atomic with respect to
other calls to {@code compareAndSet} and {@code set}, but not
necessarily with respect to other changes in the field.
|
public int | decrementAndGet(T obj)Atomically decrements by one the current value of the field of the
given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current - 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract int | get(T obj)Gets the current value held in the field of the given object managed
by this updater.
|
public int | getAndAdd(T obj, int delta)Atomically adds the given value to the current value of the field of
the given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current + delta;
if (compareAndSet(obj, current, next))
return current;
}
|
public int | getAndDecrement(T obj)Atomically decrements by one the current value of the field of the
given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current - 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public int | getAndIncrement(T obj)Atomically increments by one the current value of the field of the
given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current + 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public int | getAndSet(T obj, int newValue)Atomically sets the field of the given object managed by this updater
to the given value and returns the old value.
for (;;) {
int current = get(obj);
if (compareAndSet(obj, current, newValue))
return current;
}
|
public int | incrementAndGet(T obj)Atomically increments by one the current value of the field of the
given object managed by this updater.
for (;;) {
int current = get(obj);
int next = current + 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract void | lazySet(T obj, int newValue)Eventually sets the field of the given object managed by this
updater to the given updated value.
|
public static java.util.concurrent.atomic.AtomicIntegerFieldUpdater | newUpdater(java.lang.Class tclass, java.lang.String fieldName)Creates and returns an updater for objects with the given field.
The Class argument is needed to check that reflective types and
generic types match.
return new AtomicIntegerFieldUpdaterImpl<U>(tclass, fieldName);
|
public abstract void | set(T obj, int newValue)Sets the field of the given object managed by this updater to the
given updated value. This operation is guaranteed to act as a volatile
store with respect to subsequent invocations of {@code compareAndSet}.
|
public abstract boolean | weakCompareAndSet(T obj, int expect, int update)Atomically sets the field of the given object managed by this updater
to the given updated value if the current value {@code ==} the
expected value. This method is guaranteed to be atomic with respect to
other calls to {@code compareAndSet} and {@code set}, but not
necessarily with respect to other changes in the field.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to {@code compareAndSet}.
|