public class AtomicInteger extends AtomicInteger
AtomicInteger with richer functionality.
This class implements commonly implemented patterns of use of compareAndSet
such as getOrSetAndGetIf(int, int) and update(Function).| Constructor and Description |
|---|
AtomicInteger()
Creates a new AtomicInteger with a zero initial value.
|
AtomicInteger(int initialValue)
Creates a new AtomicInteger with the given initial value.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getOrSetAndGetIf(int oldValue,
int newValue)
Check the current value and if it matches the old value argument, set it to
the new value and return that instead.
|
int |
update(Function<Integer,Integer> 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 AtomicInteger()
public AtomicInteger(int initialValue)
initialValue - the initial valuepublic final int getOrSetAndGetIf(int oldValue,
int newValue)
oldValue - to check the current value against.newValue - the new value to set it to.public final int update(Function<Integer,Integer> newValueFactory)
newValueFactory - a Function object.Copyright © 2024 Atlassian. All rights reserved.