public final class AtomicEnum<T extends Enum<T>> extends Object
AtomicReference object to guarantee the atomicity.
This class is thread-safe.
| Constructor and Description |
|---|
AtomicEnum(T initialValue)
Constructs a new atomic enumeration object.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
compareAndSet(T expect,
T update)
Atomically set the value to the given updated value if the current value == the expected value.
|
T |
get()
Gets the current value.
|
T |
getAndSet(T newValue)
Sets the given value and returns the old value.
|
void |
set(T newValue)
Sets to the given value.
|
public AtomicEnum(T initialValue)
initialValue - the initial value of the enumerationpublic void set(T newValue)
newValue - the new valuepublic T get()
public T getAndSet(T newValue)
newValue - the new valueCopyright © 2014 The Apache Software Foundation. All rights reserved.