volatile
A Java field modifier that provides visibility and ordering guarantees for reads and writes without making compound operations atomic.
Technical Context
A volatile write happens-before a subsequent volatile read of the same variable. It is suitable for publication flags and independently updated state, but operations such as count++ remain read-modify-write sequences and still require atomic primitives or locking.
Related Concepts
- Java Memory Model
- atomicity
- visibility
- Compare-and-Swap