Intermediate
Java
Q50 / 100
What does the volatile keyword guarantee?
Correct! Well done.
Incorrect.
The correct answer is C) Reads and writes to the variable are visible to all threads immediately (no CPU caching)
C
Correct Answer
Reads and writes to the variable are visible to all threads immediately (no CPU caching)
Explanation
volatile ensures that reads and writes go directly to main memory, preventing threads from caching a stale value, but does not provide atomicity for compound operations.
Progress
50/100