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 adds the given value to the 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 sets the value to the given updated value
if the current value {@code ==} the expected value.
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|
public final long | decrementAndGet()Atomically decrements 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()Gets the current value.
return value;
|
public final long | getAndAdd(long delta)Atomically adds the given value to the current value.
while (true) {
long current = get();
long next = current + delta;
if (compareAndSet(current, next))
return current;
}
|
public final long | getAndDecrement()Atomically decrements 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 increments 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)Atomically sets to the given value and returns the old value.
while (true) {
long current = get();
if (compareAndSet(current, newValue))
return current;
}
|
public final long | incrementAndGet()Atomically increments 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 final void | lazySet(long newValue)Eventually sets to the given value.
unsafe.putOrderedLong(this, valueOffset, newValue);
|
public long | longValue()
return (long)get();
|
public final void | set(long newValue)Sets 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 sets the value 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}.
return unsafe.compareAndSwapLong(this, valueOffset, expect, update);
|