Methods Summary |
---|
public final int | addAndGet(int delta)Atomically adds the given value to the current value.
for (;;) {
int current = get();
int next = current + delta;
if (compareAndSet(current, next))
return next;
}
|
public final boolean | compareAndSet(int expect, int update)Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
return unsafe.compareAndSwapInt(this, valueOffset, expect, update);
|
public final int | decrementAndGet()Atomically decrements by one the current value.
for (;;) {
int current = get();
int next = current - 1;
if (compareAndSet(current, next))
return next;
}
|
public double | doubleValue()
return (double)get();
|
public float | floatValue()
return (float)get();
|
public final int | get()Gets the current value.
return value;
|
public final int | getAndAdd(int delta)Atomically adds the given value to the current value.
for (;;) {
int current = get();
int next = current + delta;
if (compareAndSet(current, next))
return current;
}
|
public final int | getAndDecrement()Atomically decrements by one the current value.
for (;;) {
int current = get();
int next = current - 1;
if (compareAndSet(current, next))
return current;
}
|
public final int | getAndIncrement()Atomically increments by one the current value.
for (;;) {
int current = get();
int next = current + 1;
if (compareAndSet(current, next))
return current;
}
|
public final int | getAndSet(int newValue)Atomically sets to the given value and returns the old value.
for (;;) {
int current = get();
if (compareAndSet(current, newValue))
return current;
}
|
public final int | incrementAndGet()Atomically increments by one the current value.
for (;;) {
int current = get();
int next = current + 1;
if (compareAndSet(current, next))
return next;
}
|
public int | intValue()
return get();
|
public final void | lazySet(int newValue)Eventually sets to the given value.
unsafe.putOrderedInt(this, valueOffset, newValue);
|
public long | longValue()
return (long)get();
|
public final void | set(int newValue)Sets to the given value.
value = newValue;
|
public java.lang.String | toString()Returns the String representation of the current value.
return Integer.toString(get());
|
public final boolean | weakCompareAndSet(int expect, int 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.compareAndSwapInt(this, valueOffset, expect, update);
|