| |
|
| 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 update value if the
current value is equal to the expected value. | final public boolean | get() Returns the current value. | final public boolean | getAndSet(boolean newValue) Sets to the given value and returns the previous 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 set 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 update value if the
current value is equal to the expected value. Any given
invocation of this operation may fail (return
false) spuriously, but repeated invocation when
the current value holds the expected value and no other thread
is also attempting to set the value will eventually succeed.
Parameters: expect - the expected value Parameters: update - the new value true if successful |
get | final public boolean get()(Code) | | Returns the current value.
the current value |
getAndSet | final public boolean getAndSet(boolean newValue)(Code) | | Sets to the given value and returns the previous value.
Parameters: newValue - the new value the previous value |
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 set the value to the given updated value
if the current value == the expected value.
May fail spuriously.
Parameters: expect - the expected value Parameters: update - the new value true if successful. |
|
|
|