AtomicInteger

Comprehensive guide to AtomicInteger.

If you are interviewing, consider buying our number#1 course for Java Multithreading Interviews.

Overview

The AtomicInteger class represents an integer value that can be updated atomically, i.e. the read-modify-write operation can be executed atomically upon an instance of AtomicInteger. The class extends Number.

AtomicInteger makes for great counters as it uses the compare-and-swap (CAS) instruction under the hood which doesn’t ...