“When a field is declared volatile, the compiler and runtime are put on notice that this variable is shared and that operations on it should not be reordered with other memory operations. Volatile variables are not cached in registers or in caches where they are hidden from other processors, so a read of a volatile variable always returns the most recent write by any thread.”

Brian Goetz

Brian Goetz - “When a field is declared volatile, the...” 1

Similar quotes

“Locking can guarantee both visibility and atomicity; volatile variables can only guarantee visibility.”

Brian Goetz
Read more

“book variables, student variables, and school variables.”

Teri S. Lesesne
Read more

“Compound actions on shared state, such as incrementing a hit counter (read-modify-write) or lazy initialization (check-then-act), must be made atomic to avoid race conditions. Holding a lock for the entire duration of a compound action can make that compound action atomic. However, just wrapping the compound action with a synchronized block is not sufficient; if synchronization is used to coordinate access to a variable, it is needed everywhere that variable is accessed. Further, when using locks to coordinate access to a variable, the same lock must be used wherever that variable is accessed.”

Brian Goetz
Read more

“In mathematics, in place of characters, you have variables or unknowns. If I'm trying to plot a theorem, I try to imagine these variables interacting with each other. The boundary of their interaction is the theorem.”

Manil Suri
Read more

“Life is volatile.”

Robert J. Pajer
Read more