Skip to content
Sharp

Concurrency basics · interview question

How does 'volatile' influence the Java Memory Model's ordering of operations?

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

Correct answer

C. It establishes a 'happens-before' relationship for reads/writes

Why

Volatile variables create a 'happens-before' relationship between writes and subsequent reads, ensuring that changes are visible and ordered correctly in the Java Memory Model.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →