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:


If you enjoy this Java programming article, please share with friends and colleagues. Follow the author on Twitter for the latest news and rants.

Editorial page content written by Neil Coffey. Copyright © Javamex UK 2021. All rights reserved.