Methods Summary |
---|
private static native boolean | VMSupportsCS8()Returns whether underlying JVM supports lockless CompareAndSet
for longs. Called only once and cached in VM_SUPPORTS_LONG_CAS.
|
public final long | addAndGet(long delta)Atomically add the given value to current value.
for (;;) {
long current = get();
long next = current + delta;
if (compareAndSet(current, next))
return next;
}
|
public final boolean | compareAndSet(long expect, long update)Atomically set the value to the given updated value
if the current value == the expected value.
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|
public final long | decrementAndGet()Atomically decrement by one the current value.
for (;;) {
long current = get();
long next = current - 1;
if (compareAndSet(current, next))
return next;
}
|
public double | doubleValue()
return (double)get();
|
public float | floatValue()
return (float)get();
|
public final long | get()Get the current value.
return value;
|
public final long | getAndAdd(long delta)Atomically add the given value to current value.
while (true) {
long current = get();
long next = current + delta;
if (compareAndSet(current, next))
return current;
}
|
public final long | getAndDecrement()Atomically decrement by one the current value.
while (true) {
long current = get();
long next = current - 1;
if (compareAndSet(current, next))
return current;
}
|
public final long | getAndIncrement()Atomically increment by one the current value.
while (true) {
long current = get();
long next = current + 1;
if (compareAndSet(current, next))
return current;
}
|
public final long | getAndSet(long newValue)Set to the give value and return the old value.
while (true) {
long current = get();
if (compareAndSet(current, newValue))
return current;
}
|
public final long | incrementAndGet()Atomically increment by one the current value.
for (;;) {
long current = get();
long next = current + 1;
if (compareAndSet(current, next))
return next;
}
|
public int | intValue()
return (int)get();
|
public long | longValue()
return (long)get();
|
public final void | set(long newValue)Set to the given value.
value = newValue;
|
public java.lang.String | toString()Returns the String representation of the current value.
return Long.toString(get());
|
public final boolean | weakCompareAndSet(long expect, long update)Atomically set the value to the given updated value
if the current value == the expected value.
May fail spuriously.
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|