java - volatile类型的变量多线程访问的问题
怪我咯
怪我咯 2017-04-18 10:42:14
0
2
505
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
Peter_Zhu

For Java's memory model, each volatile will keep a copy in the working memory of the thread, but the Java memory model ensures the visibility of variables by adding a special mechanism to volatile variables.
The thread must immediately save it to the main memory after modifying the volatile type variable. Before using the variable, it must load the data from the main memory. At the same time, it also performs some operations that prohibit instruction reordering. For the working memory (private memory) of each thread, there are moments when volatile variables are inconsistent, but for the execution engine, the above rules ensure that the variables are consistent.

伊谢尔伦

No, I recommend a blog

Java concurrent programming volatile keyword analysis

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!