当前位置:网站首页>"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
边栏推荐
- Pytorch training code writing skills, dataloader, Einstein logo
- 变分(Calculus of variations)的概念及运算规则
- Practical guide for network security emergency response technology (Qianxin)
- [C题目]力扣876. 链表的中间结点
- D2. Chopping Carrots (Hard Version) (每日一题)
- Ssh server rejected password
- Alibaba cloud installs mysql5.7
- 冈萨雷斯 数字图像处理 第一章绪论
- Gonzalez Digital Image Processing Chapter 1 Introduction
- Jqgrid select all cancel single line click cancel event
猜你喜欢

45padding won't open the box

Deng Qinglin, a technical expert of Alibaba cloud: Best Practices for disaster recovery and remote multi activity across availability zones on cloud

D2. picking carrots (hard version) (one question per day)

IP address classification, which determines whether a network segment is a subnet supernetwork

Melody + realsense d435i configuration and error resolution

filters获取data中的数据;filters使用data中的数据

基于浏览器的分屏阅读

English语法_不定代词 - other / another

51 single chip microcomputer learning notes (2)

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
随机推荐
没错,请求DNS服务器还可以使用UDP协议
Filters get the data in data; Filters use data in data
Wechat official account official environment online deployment, third-party public platform access
GameFramework制作游戏(二)制作UI界面
Dpkg package download addresses of various platforms (including arm64)
I2C设备驱动程序的层次结构
SSH服务器拒绝了密码
MySQL的登陆【数据库系统】
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]
直播课堂系统05-后台管理系统
Awk from entry to earth (24) extract the IP of the instruction network card
I2C device driver hierarchy
Several methods of spark parameter configuration
Thymeleaf setting disabled
BIO、NIO、AIO示例
SSM framework integration, simple case
阿里云技术专家邓青琳:云上跨可用区容灾和异地多活最佳实践
Educational codeforces round 132 (rated for Div. 2) C, d+ac automata
I hope some suggestions on SQL optimization can help you who are tortured by SQL like me
物理量与单位符号的书写标准