...
Using volatile
variables guarantees a weaker form of sequential consistency because statements prior to a volatile
access appear to occur in program order with respect to the statement that writes to the volatile
variable, to a thread that is attempting to read the same volatile
variable. The previous statements may, however, be freely reordered and may not be sequential consistent with respect to each other. This makes the cost of using volatile
cheaper than synchronizing every piece of code.
...