Skip to main content

AtomicBoolean

class AtomicBoolean

An AtomicBoolean is a boolean value that need to be updated atomically, see java.util.concurrent.atomic package to view atomic specifications.


public class AtomicBoolean

— Constructors (2) —

ConstructorDescription
AtomicBoolean()Creates a new AtomicBoolean with the default value set to false.
AtomicBoolean(boolean value)Creates a new AtomicBoolean with the default value defined to be "value" argumento.

— Methods (6) —

NameDescription
boolean get()Returns the current boolean value.
void set(boolean value)Set the current boolean value to be "value" argument.
void lazySet(boolean value)Set the current boolean value to be "value" argument at any time.
boolean getAndSet(boolean value)Returns the current boolean value and set the current value to be "value" argument.
boolean compareAndSet(boolean expect, boolean update)Compare the current value with "expect" argument, if is true, the current value will be set to be "update" argument.
boolean weakCompareAndSet(boolean expect, boolean update)Compare the current value with "expect", if is true, the current value will be set to be "update" argument.