当前位置:网站首页>"Ask every day" what is volatile
"Ask every day" what is volatile
2022-07-25 14:52:00 【Senior fishing Engineer】
Memory semantics
volatile Write : When you write a volatile Variable time ,JMM All shared variables in the local memory of this thread will be flushed to the main memory . Be careful , It's all , Not just volatile Variable
volatile read : When reading a volatile Variable time ,JMM The local memory of this thread will be set as invalid , Then read the shared variables from main memory .
If the above two steps are taken together , The reading thread is reading a volatile Variable time , The writing thread is writing this volatile All operations on shared variables before variables will immediately become visible to the reader thread .
Implementation of memory semantics
I said before , Reordering is divided into compiler and processor rearrangement . In order to achieve volatile What about the semantics of ,JMM Will limit these two reordering .
For compilers :
- For the latter operation volatile When writing , No matter what the previous operation is , Can't reorder .
- The previous operation is volatile When reading , No matter what the latter operation is , Can't reorder .
- Previous operation volatile Write , The latter operation volatile read , Cannot reorder .
For processors :
When the compiler generates bytecode , A memory barrier is inserted in the instruction sequence to prevent a particular type of processor reordering .
Recommended reading :Java Theory and practice : Use... Correctly Volatile Variable
边栏推荐
- Is it safe for Guolian securities to buy shares and open an account?
- LeetCode_字符串_中等_151.颠倒字符串中的单词
- How to use the random number function of JMeter
- PHP implements non blocking (concurrent) request mode through native curl
- MySQL的登陆【数据库系统】
- The main function of component procurement system, digital procurement helps component enterprises develop rapidly
- As methods for viewing and excluding dependencies
- Gson and fastjson
- 44 新浪导航 ,小米边栏 练习
- 各种平台dpkg包下载地址(包括arm64)
猜你喜欢

Realsense-Ros安装配置介绍与问题解决

51 single chip microcomputer learning notes (1)

44 Sina navigation, Xiaomi sidebar exercise

L1 and L2 regularization

The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path

I hope some suggestions on SQL optimization can help you who are tortured by SQL like me

Niuke multi school E G J L
![优质数对的数目[位运算特点+抽象能力考察+分组快速统计]](/img/c9/8f8f0934111f7ae8f8abd656d92f12.png)
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]

Resource not found: rgbd_ Launch solution

39 simple version of millet sidebar exercise
随机推荐
牛客多校 E G J L
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]
微信公众号正式环境上线部署,第三方公众平台接入
(original) customize a scrolling recyclerview
Practical guide for network security emergency response technology (Qianxin)
Under the epidemic, the biomedical industry may usher in breakthrough development
Filters get the data in data; Filters use data in data
I hope some suggestions on SQL optimization can help you who are tortured by SQL like me
Overview of cloud security technology development
32 chrome调试工具的使用
[nuxt 3] (XI) transmission & module
006操作符简介
sudo rosdep init Error ROS安装问题解决方案
SSM framework integration, simple case
English grammar_ Indefinite pronoun - other / other
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
51单片机学习笔记(1)
Spark parameter adjustment and tuning
Examples of bio, NiO, AIO
D2. Chopping Carrots (Hard Version) (每日一题)