The Atomic classes in Java 5

In our outline of how synchronization works, we saw that under the hood, a machine instruction generally called Compare-And-Swap (CAS) was used to effectively read and write to a memory location at the same time. From Java 5 onwards, CAS and related instructions are effectively exposed at the level of the Java programmer in the form of a series of "atomic" classes in the java.util.concurrent package: