Intermediate Java
Q74 / 100

What does AtomicInteger provide over volatile int?

Correct! Well done.

Incorrect.

The correct answer is B) Thread-safe compound operations like compareAndSet and incrementAndGet

B

Correct Answer

Thread-safe compound operations like compareAndSet and incrementAndGet

Explanation

volatile ensures visibility but not atomicity for compound operations. AtomicInteger uses CPU compare-and-swap (CAS) for lock-free atomic increments and conditional updates.

Progress
74/100