This question evaluates a candidate's understanding of Java's volatile semantics, specifically memory visibility, happens-before ordering, restrictions on instruction reordering around volatile accesses, and limitations such as lack of atomicity and contrasts with synchronized/locks.
What does the volatile keyword guarantee in Java's memory model? Describe visibility, ordering (happens-before), and restrictions on instruction reordering around volatile accesses. Clarify what volatile does not guarantee (e.g., atomicity of compound operations) and compare it with synchronized/locks; give example use cases.