boolean
value that may be updated atomically. See the
VarHandle
specification for descriptions of the properties
of atomic accesses. An AtomicBoolean
is used in
applications such as atomically updated flags, and cannot be used
as a replacement for a java.lang.Boolean
.
Modifier and Type | Field and Description |
---|---|
private static final long | |
private static final VarHandle | |
private volatile int |
Access | Constructor and Description |
---|---|
public | AtomicBoolean(boolean
the initial value initialValue)Creates a new |
public |
Modifier and Type | Method and Description |
---|---|
public final boolean | Returns: the witness value, which will be the same as the expected value if successfulthe expected value expectedValue, boolean the new value newValue)Atomically sets the value to |
public final boolean | Returns: the witness value, which will be the same as the expected value if successfulthe expected value expectedValue, boolean the new value newValue)Atomically sets the value to |
public final boolean | Returns: the witness value, which will be the same as the expected value if successfulthe expected value expectedValue, boolean the new value newValue)Atomically sets the value to |
public final boolean | Returns: true if successful. False return indicates that
the actual value was not equal to the expected value.the expected value expectedValue, boolean the new value newValue)Atomically sets the value to |
public final boolean | Returns: the current valueReturns the current value,
with memory effects as specified by |
public final boolean | Returns: the valueReturns the current value,
with memory effects as specified by |
public final boolean | Returns: the previous valuethe new value newValue)Atomically sets the value to |
public final boolean | Returns: the valueReturns the current value,
with memory effects as specified by |
public final boolean | Returns: the valueReturns the current value, with memory semantics of reading as
if the variable was declared non- |
public final void | lazySet(boolean
the new value newValue)Sets the value to |
public final void | set(boolean
the new value newValue)Sets the value to |
public final void | setOpaque(boolean
the new value newValue)Sets the value to |
public final void | setPlain(boolean
the new value newValue)Sets the value to |
public final void | setRelease(boolean
the new value newValue)Sets the value to |
public String | Returns: the String representation of the current valueOverrides java. Returns the String representation of the current value. |
public boolean | Returns: true if successfulthe expected value expectedValue, boolean the new value newValue)
Deprecated
since 9. This method has plain memory effects but the method
name implies volatile memory effects (see methods such as
compareAndExchange and compareAndSet ).
Possibly atomically sets the value to |
public final boolean | Returns: true if successfulthe expected value expectedValue, boolean the new value newValue)Possibly atomically sets the value to |
public boolean | Returns: true if successfulthe expected value expectedValue, boolean the new value newValue)Possibly atomically sets the value to |
public final boolean | Returns: true if successfulthe expected value expectedValue, boolean the new value newValue)Possibly atomically sets the value to |
public final boolean | Returns: true if successfulthe expected value expectedValue, boolean the new value newValue)Possibly atomically sets the value to |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID |
VALUE | back to summary |
---|---|
private static final VarHandle VALUE |
value | back to summary |
---|---|
private volatile int value |
AtomicBoolean | back to summary |
---|---|
public AtomicBoolean(boolean initialValue) Creates a new
|
AtomicBoolean | back to summary |
---|---|
public AtomicBoolean() Creates a new |
compareAndExchange | back to summary |
---|---|
public final boolean compareAndExchange(boolean expectedValue, boolean newValue) Atomically sets the value to
|
compareAndExchangeAcquire | back to summary |
---|---|
public final boolean compareAndExchangeAcquire(boolean expectedValue, boolean newValue) Atomically sets the value to
|
compareAndExchangeRelease | back to summary |
---|---|
public final boolean compareAndExchangeRelease(boolean expectedValue, boolean newValue) Atomically sets the value to
|
compareAndSet | back to summary |
---|---|
public final boolean compareAndSet(boolean expectedValue, boolean newValue) Atomically sets the value to
|
get | back to summary |
---|---|
public final boolean get() Returns the current value,
with memory effects as specified by
|
getAcquire | back to summary |
---|---|
public final boolean getAcquire() Returns the current value,
with memory effects as specified by
|
getAndSet | back to summary |
---|---|
public final boolean getAndSet(boolean newValue) Atomically sets the value to
|
getOpaque | back to summary |
---|---|
public final boolean getOpaque() Returns the current value,
with memory effects as specified by
|
getPlain | back to summary |
---|---|
public final boolean getPlain() Returns the current value, with memory semantics of reading as
if the variable was declared non-
|
lazySet | back to summary |
---|---|
public final void lazySet(boolean newValue) Sets the value to
|
set | back to summary |
---|---|
public final void set(boolean newValue) Sets the value to
|
setOpaque | back to summary |
---|---|
public final void setOpaque(boolean newValue) Sets the value to
|
setPlain | back to summary |
---|---|
public final void setPlain(boolean newValue) Sets the value to
|
setRelease | back to summary |
---|---|
public final void setRelease(boolean newValue) Sets the value to
|
toString | back to summary |
---|---|
public String toString() Overrides java. Returns the String representation of the current value.
|
weakCompareAndSet | back to summary |
---|---|
public boolean weakCompareAndSet(boolean expectedValue, boolean newValue)
Deprecated since 9. This method has plain memory effects but the method
name implies volatile memory effects (see methods such as
Possibly atomically sets the value to
|
weakCompareAndSetAcquire | back to summary |
---|---|
public final boolean weakCompareAndSetAcquire(boolean expectedValue, boolean newValue) Possibly atomically sets the value to
|
weakCompareAndSetPlain | back to summary |
---|---|
public boolean weakCompareAndSetPlain(boolean expectedValue, boolean newValue) Possibly atomically sets the value to
|
weakCompareAndSetRelease | back to summary |
---|---|
public final boolean weakCompareAndSetRelease(boolean expectedValue, boolean newValue) Possibly atomically sets the value to
|
weakCompareAndSetVolatile | back to summary |
---|---|
public final boolean weakCompareAndSetVolatile(boolean expectedValue, boolean newValue) Possibly atomically sets the value to
|