Skip to content
Sharp

Concurrency basics · interview question

Which of the following scenarios would require both 'volatile' and synchronization?

Multiple choiceHardchapter-15-curatedpremiumconcurrencythe-volatile-keyword
Choose one answer
Answer and explanation

Correct answer

A. Atomic update of a shared counter

Why

Volatile ensures visibility, but atomic updates require synchronization to prevent race conditions. Volatile alone cannot provide atomicity for compound actions.

Test yourself on Concurrency basics

A free test with instant, explained results. No account needed.

Start free test
All Concurrency basics questions →