public final class Atomics
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compareExchange(java.util.concurrent.atomic.AtomicBoolean ref,
boolean compareWith,
boolean newValue)
Atomically compares the content of
ref with the compareWith
value and
replaces it with the newValue if they equal. |
static int |
compareExchange(java.util.concurrent.atomic.AtomicInteger ref,
int compareWith,
int newValue)
Atomically compares the content of
ref with the compareWith
value and
replaces it with the newValue if they equal. |
static long |
compareExchange(java.util.concurrent.atomic.AtomicLong ref,
long compareWith,
long newValue)
Atomically compares the content of
ref with the compareWith
value and
replaces it with the newValue if they equal. |
static <T> T |
compareExchange(java.util.concurrent.atomic.AtomicReference<T> ref,
T compareWith,
T newValue)
Atomically compares the content of
ref with the compareWith
value by using nullsafe object equality and
replaces it with the newValue if they equal. |
public static <T> T compareExchange(@Nonnull
java.util.concurrent.atomic.AtomicReference<T> ref,
T compareWith,
T newValue)
ref with the compareWith
value by using nullsafe object equality and
replaces it with the newValue if they equal. The method
returns the old value of ref regardless of whether the exchange actually happened.T - the element typeref - the target of the exchangecompareWith - the value to compare againstnewValue - the the new value to replace withpublic static boolean compareExchange(@Nonnull
java.util.concurrent.atomic.AtomicBoolean ref,
boolean compareWith,
boolean newValue)
ref with the compareWith
value and
replaces it with the newValue if they equal. The method
returns the old value of ref regardless of whether the exchange actually happened.ref - the target of the exchangecompareWith - the value to compare againstnewValue - the the new value to replace withpublic static int compareExchange(@Nonnull
java.util.concurrent.atomic.AtomicInteger ref,
int compareWith,
int newValue)
ref with the compareWith
value and
replaces it with the newValue if they equal. The method
returns the old value of ref regardless of whether the exchange actually happened.ref - the target of the exchangecompareWith - the value to compare againstnewValue - the the new value to replace withpublic static long compareExchange(@Nonnull
java.util.concurrent.atomic.AtomicLong ref,
long compareWith,
long newValue)
ref with the compareWith
value and
replaces it with the newValue if they equal. The method
returns the old value of ref regardless of whether the exchange actually happened.ref - the target of the exchangecompareWith - the value to compare againstnewValue - the the new value to replace with