atomic variable

A variable, such as AtomicInteger, whose updates like incrementAndGet happen as one indivisible step that no other thread can interrupt.

In more detail

Atomic classes in java.util.concurrent.atomic fix simple races on a single value without a lock. They do not protect an invariant that spans several variables; that needs a lock.

Example

counter.incrementAndGet();

Related terms

Taught in

References

Certification courses