java - JMM为什么要规定普通写和volatile读不能重排序?
天蓬老师
天蓬老师 2017-04-18 09:41:49
0
1
896
是否能重排序 第二个操作
第一个操作 普通读/写 volatile读 volatile写
普通读/写 YES NO YES
volatile读 NO NO NO
volatile写 YES NO NO

我理解的对volatile变量的重排序(编译器重排序和处理器重排序),主要目的是为了实现对volatile的写,Happend-Before对volatile的读

所以,按照我理解的话,并不需要像图表中那么严谨

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
洪涛

In the case of multi-threading, there is a synchronization problem between the thread working memory and the main memory. Volatile is only available immediately on the main memory

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!