public class AtomicLong extends AtomicLong
AtomicLong with richer functionality.
This class implements commonly implemented patterns of use of compareAndSet
such as getOrSetAndGetIf(long, long) and update(Function).| Constructor and Description |
|---|
AtomicLong()
Creates a new AtomicLong with a zero initial value.
|
AtomicLong(long initialValue)
Creates a new AtomicLong with the given initial value.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getOrSetAndGetIf(long oldValue,
long newValue)
Check the current value and if it matches the old value argument, set it to
the new value and return that instead.
|
long |
update(Function<Long,Long> newValueFactory)
Do the actual update.
|
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, toString, updateAndGet, weakCompareAndSetbyteValue, shortValuepublic AtomicLong()
public AtomicLong(long initialValue)
initialValue - the initial valuepublic final long getOrSetAndGetIf(long oldValue,
long newValue)
oldValue - to check the current value againstnewValue - the new value to set it topublic final long update(Function<Long,Long> newValueFactory)
newValueFactory - a Function object.Copyright © 2024 Atlassian. All rights reserved.