edu.emory.mathcs.backport.java.util.concurrent.atomic
public class AtomicBoolean extends Object implements Serializable
Since: 1.5
Constructor Summary | |
---|---|
AtomicBoolean(boolean initialValue)
Creates a new {@code AtomicBoolean} with the given initial value.
| |
AtomicBoolean()
Creates a new {@code AtomicBoolean} with initial value {@code false}. |
Method Summary | |
---|---|
boolean | compareAndSet(boolean expect, boolean update)
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
|
boolean | get()
Returns the current value.
|
boolean | getAndSet(boolean newValue)
Atomically sets to the given value and returns the previous value.
|
void | lazySet(boolean newValue)
Eventually sets to the given value.
|
void | set(boolean newValue)
Unconditionally sets to the given value.
|
String | toString()
Returns the String representation of the current value. |
boolean | weakCompareAndSet(boolean expect, boolean update)
Atomically sets the value to the given updated value
if the current value {@code ==} the expected value.
|
Parameters: initialValue the initial value
Parameters: expect the expected value update the new value
Returns: true if successful. False return indicates that the actual value was not equal to the expected value.
Returns: the current value
Parameters: newValue the new value
Returns: the previous value
Parameters: newValue the new value
Since: 1.6
Parameters: newValue the new value
Returns: the String representation of the current value.
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}.
Parameters: expect the expected value update the new value
Returns: true if successful.