O'Reilly logo
  • ted won thinks this is interesting:

For every read request for a volatile variable, a thread reads the value from the main memory. For every write request for a volatile variable, a thread writes the value to the main memory. In other words, a thread does not cache the value of a volatile variable in its working memory. Note that using a volatile variable is useful only in a multi-threaded environment for variables that are shared among threads. It is faster and cheaper than using a synchronized block.