More on Atomics
Learn about the different categories of atomic classes and their performance in comparison to locks.
We'll cover the following...
Taxonomy of atomic classes
There are a total of sixteen atomic classes divided into four groups:
- Scalars
- Field updaters
- Arrays
- Compound variables
Most well-known and commonly used are the scalar ones such as AtomicInteger
, AtomicLong
, AtomicReference
, which support the CAS (compare-and-set). Other primitive types such as double and float can be simulated by casting short
or byte
values to and from int
and using methods floatToIntBits()
and doubleToLongBits()
for floating point numbers. ...