| |
|
| java.lang.Object java.util.concurrent.atomic.AtomicBoolean
AtomicBoolean | public class AtomicBoolean implements java.io.Serializable(Code) | | A
boolean value that may be updated atomically. See the
java.util.concurrent.atomic package specification for
description of the properties of atomic variables. An
AtomicBoolean is used in applications such as atomically
updated flags, and cannot be used as a replacement for a
java.lang.Boolean .
since: 1.5 author: Doug Lea |
Constructor Summary | |
public | AtomicBoolean(boolean initialValue) Creates a new
AtomicBoolean with the given initial value. | public | AtomicBoolean() Creates a new
AtomicBoolean with initial value
false . |
Method Summary | |
final public boolean | compareAndSet(boolean expect, boolean update) Atomically sets the value to the given updated value
if the current value
== the expected value.
Parameters: expect - the expected value Parameters: update - the new value true if successful. | final public boolean | get() Returns the current value. | final public boolean | getAndSet(boolean newValue) Atomically sets to the given value and returns the previous value. | final public void | lazySet(boolean newValue) Eventually sets to the given value. | final public void | set(boolean newValue) Unconditionally sets to the given value. | public String | toString() Returns the String representation of the current value. | public boolean | weakCompareAndSet(boolean expect, boolean update) Atomically sets the value to the given updated value
if the current value
== the expected value. |
AtomicBoolean | public AtomicBoolean(boolean initialValue)(Code) | | Creates a new
AtomicBoolean with the given initial value.
Parameters: initialValue - the initial value |
AtomicBoolean | public AtomicBoolean()(Code) | | Creates a new
AtomicBoolean with initial value
false .
|
compareAndSet | final public boolean compareAndSet(boolean expect, boolean update)(Code) | | Atomically sets the value to the given updated value
if the current value
== the expected value.
Parameters: expect - the expected value Parameters: update - the new value true if successful. False return indicates thatthe actual value was not equal to the expected value. |
get | final public boolean get()(Code) | | Returns the current value.
the current value |
getAndSet | final public boolean getAndSet(boolean newValue)(Code) | | Atomically sets to the given value and returns the previous value.
Parameters: newValue - the new value the previous value |
lazySet | final public void lazySet(boolean newValue)(Code) | | Eventually sets to the given value.
Parameters: newValue - the new value since: 1.6 |
set | final public void set(boolean newValue)(Code) | | Unconditionally sets to the given value.
Parameters: newValue - the new value |
toString | public String toString()(Code) | | Returns the String representation of the current value.
the String representation of the current value. |
weakCompareAndSet | public boolean weakCompareAndSet(boolean expect, boolean update)(Code) | | Atomically sets the value to the given updated value
if the current value
== the expected value.
May fail spuriously
and does not provide ordering guarantees, so is only rarely an
appropriate alternative to
compareAndSet .
Parameters: expect - the expected value Parameters: update - the new value true if successful. |
|
|
|