Methods Summary |
---|
public long | addAndGet(T obj, long delta)Atomically adds the given value to the current value of the field of
the given object managed by this updater.
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 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 long | decrementAndGet(T obj)Atomically decrements by one the current value of the field of the
given object managed by this updater.
for (;;) {
long current = get(obj);
long next = current - 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract long | get(T obj)Gets the current value held in the field of the given object managed
by this updater.
|
public long | getAndAdd(T obj, long delta)Atomically adds the given value to the current value of the field of
the given object managed by this updater.
for (;;) {
long current = get(obj);
long next = current + delta;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndDecrement(T obj)Atomically decrements by one the current value of the field of the
given object managed by this updater.
for (;;) {
long current = get(obj);
long next = current - 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndIncrement(T obj)Atomically increments by one the current value of the field of the
given object managed by this updater.
for (;;) {
long current = get(obj);
long next = current + 1;
if (compareAndSet(obj, current, next))
return current;
}
|
public long | getAndSet(T obj, long newValue)Atomically sets the field of the given object managed by this updater
to the given value and returns the old value.
for (;;) {
long current = get(obj);
if (compareAndSet(obj, current, newValue))
return current;
}
|
public long | incrementAndGet(T obj)Atomically increments by one the current value of the field of the
given object managed by this updater.
for (;;) {
long current = get(obj);
long next = current + 1;
if (compareAndSet(obj, current, next))
return next;
}
|
public abstract void | lazySet(T obj, long newValue)Eventually sets the field of the given object managed by this
updater to the given updated value.
|
public static java.util.concurrent.atomic.AtomicLongFieldUpdater | 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.
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)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, long expect, long 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}.
|