Skip to content
Sharp

Concurrency basics · interview question

In a multicore system, what role does 'volatile' play regarding CPU cache?

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

Correct answer

A. It ensures updates to a volatile variable are propagated to main memory immediately

Why

Volatile ensures that whenever a volatile variable is updated, the change is immediately written to main memory, and any read of the variable will fetch the latest value from main memory.

Test yourself on Concurrency basics

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

Start free test
All Concurrency basics questions →