Methods Summary |
---|
public long | addAndGet(T obj, long delta)Atomically add the given value to current value.
for (;;) {
long current = get(obj);
long next = current + delta;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract boolean | compareAndSet(T obj, long expect, long update)Atomically set the value of the field of the given object managed
by this Updater to the given updated value if the current value
== the expected value. This method is guaranteed to be
atomic with respect to other calls to compareAndSet and
set, but not necessarily with respect to other
changes in the field.
|
public long | decrementAndGet(T obj)Atomically decrement by one the current value.
for (;;) {
long current = get(obj);
long next = current - 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract long | get(T obj)Get the current value held in the field by the given object.
|
public long | getAndAdd(T obj, long delta)Atomically add the given value to current value.
for (;;) {
long current = get(obj);
long next = current + delta;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndDecrement(T obj)Atomically decrement by one the current value.
for (;;) {
long current = get(obj);
long next = current - 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndIncrement(T obj)Atomically increment by one the current value.
for (;;) {
long current = get(obj);
long next = current + 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndSet(T obj, long newValue)Set to the given value and return the old value.
for (;;) {
long current = get(obj);
if (compareAndSet(obj, current, newValue))
return current;
}
|
public long | incrementAndGet(T obj)Atomically increment by one the current value.
for (;;) {
long current = get(obj);
long next = current + 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public static java.util.concurrent.atomic.AtomicLongFieldUpdater | newUpdater(java.lang.Class tclass, java.lang.String fieldName)Creates an updater for objects with the given field. The Class
argument is needed to check that reflective types and generic
types match.
if (AtomicLong.VM_SUPPORTS_LONG_CAS)
return new CASUpdater<U>(tclass, fieldName);
else
return new LockedUpdater<U>(tclass, fieldName);
|
public abstract void | set(T obj, long newValue)Set the field of the given object managed by this updater. This
operation is guaranteed to act as a volatile store with respect
to subsequent invocations of compareAndSet.
|
public abstract boolean | weakCompareAndSet(T obj, long expect, long update)Atomically set the value of the field of the given object managed
by this Updater to the given updated value if the current value
== the expected value. This method is guaranteed to be
atomic with respect to other calls to compareAndSet and
set, but not necessarily with respect to other
changes in the field, and may fail spuriously.
|