public abstract class AtomicLong extends Object
| Constructor and Description |
|---|
AtomicLong() |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
attemptAdd(long k)
Behaviorally equivalent to:
|
abstract boolean |
attemptIncrememt()
Behaviorally equivalent to:
|
abstract boolean |
attemptSet(long newValue)
Behaviorally equivalent to:
|
abstract boolean |
attemptUpdate(long oldValue,
long newValue)
Attempt to set the value to newValue only if it is currently oldValue.
|
abstract long |
get()
Get the current value, with VOLATILE-ACQUIRE memory semantics.
|
static AtomicLong |
newAtomicLong(long initialValue)
Factory method to create instance of underlying implementation.
|
public AtomicLong()
public static AtomicLong newAtomicLong(long initialValue)
public abstract long get()
public abstract boolean attemptUpdate(long oldValue, long newValue)
public abstract boolean attemptSet(long newValue)
attemptUpdate(get(), newValue);
public abstract boolean attemptIncrememt()
long v = get(); attemptUpdate(v, v+1);Rationale: Automates and speeds up a very common usage.
public abstract boolean attemptAdd(long k)
long v = get(); attemptUpdate(v, v+k);