volatile总结研究

    之前有volatile的帖,但volatile内容不少,发个总结研究。

http://www.ibm.com/developerworks/java/library/j-jtp06197.html

 

Volatile variables share the visibility features of synchronized , but none of the atomicity features. This means that threads will automatically see the most up-to-date value for volatile variables. They can be used to provide thread safety, but only in a very restricted set of cases: those that do not impose constraints between multiple variables or between a variable's current value and its future values. So volatile alone is not strong enough to implement a counter, a mutex, or any class that has invariants that relate multiple variables (such as "start <=end").

 

我觉得就这一段,已经很全面地概括了

你可能感兴趣的:(thread,html,IBM,J#,UP)