This package includes classes that provide
atomic operations on boolean, integer, and reference values.
Instances of the classes defined here have the properties of
volatile fields but also add atomic operations
like the canonical compareAndSet( ), which
verifies that the field holds an expected value, and, if it does,
sets it to a new value. The classes also define a
weakCompareAndSet( ) method that may be more
efficient than compareAndSet( ) but may also fail
to set the value even when the field holds the expected value.
The "Array" classes provide atomic
access to arrays of values and provide volatile
access semantics for array elements, which is not possible with the
volatile modifier itself. The
"FieldUpdater" classes use
reflection to provide atomic operations on a named
volatile field of an existing class. The
AtomicMarkableReference class and
AtomicStampedReference class maintain a reference
value and an associated boolean or
int value and allow the two values to be
atomically manipulated together. These classes can be useful in
concurrent algorithms that detect concurrent updates with version
numbering, for example.
Most implementations of this package rely on low-level atomic
instructions in the underlying CPU and perform atomic operations
without the overhead of locking.