More on Atomics

Learn about the different categories of atomic classes and their performance in comparison to locks.

Taxonomy of atomic classes

There are a total of sixteen atomic classes divided into four groups:

  1. Scalars
  2. Field updaters
  3. Arrays
  4. 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. ...