当前位置:网站首页>[multithreading] non atomic agreement of long and double
[multithreading] non atomic agreement of long and double
2022-07-28 09:27:00 【Tanyue Jianzhi Dachang】
long and double The nonatomic agreement of
Java Memory model requirements lock、unlock、read、load、assign、use、store、write this 8 All operations are atomic , But for 64 Bit data type (double、long) Defines relatively loose regulations : Allowing virtual machines will not be volatile Embellished 64 The read-write operation of bit data is divided into two operations 32 Bit operation , That is, the virtual machine can be allowed without guarantee 64 Bit data type load、store、read and write Atomicity of operation .
Possible problems caused by non atomic agreements
If there are multiple threads sharing an undeclared volatile Of long or double Variable of type , And read and modify it at the same time , It is possible that a thread will read " Half a variable " Or half correct and half wrong failure data .
Solution in practical application
Because of the problems that may be caused by the above , It's bound to be right long and double Type variables should be operated with volatile keyword , In fact, it is as follows :
1、64 Bit java This problem does not exist in virtual machines , Can operate 64 A data
2、 Currently commercial JVM Basically, they will 64 The operation of bit data is implemented as an atomic operation
So we usually don't need to write code with long and double Variables are specifically declared as volatile
边栏推荐
- 【vscode】vscode使用
- 1.5 merge\rebase\revert\stash\branch
- MQTT.js 入门教程:学习笔记
- c# 有符号和无符号字节变量
- Informatics Olympiad all in one 1617: circle game | 1875: [13noip improvement group] circle game | Luogu p1965 [noip2013 improvement group] circle game
- Personal blog applet
- Openshift 4 - use verticalpodautoscaler to optimize application resource request and limit
- RGB-T追踪——【多模态融合】Visible-Thermal UAV Tracking: A Large-Scale Benchmark and New Baseline
- MySQL 8.0.30 GA
- 【C语言】详解顺序表(SeqList)
猜你喜欢

Dn-detr paper accuracy, and analyze its model structure & 2022 CVPR paper

Promise learning notes

51 single chip microcomputer storage: EEPROM (I2C)

Title and answer of work permit for safety management personnel of hazardous chemical business units in 2022

final关键字和枚举类型

数据库核心体系

《PyTorch深度学习实践》第九课多分类问题(手写数字MNIST)

From development to testing: I started from scratch and worked for six years of automated testing

Machine learning (11) -- time series analysis

Introduction to official account
随机推荐
VR panoramic shooting helps promote the diversity of B & B
Title and answer of work permit for safety management personnel of hazardous chemical business units in 2022
376. Swing sequence [greedy, dynamic planning -----]
Activiti startup error: cannot create poolableconnectionfactory (could not create connection to database server
What is it like to use gbase C API to execute stored procedures?
数据泄漏、删除事件频发,企业应如何构建安全防线?
DAPP safety summary and typical safety incident analysis
2022 high voltage electrician examination simulated 100 questions and simulated examination
[vscode] vscode usage
sql server 的关键字在哪张系统表?
AMQ streams (1) of openshift 4 - multiple consumers receive data from partition
[solution] error in [eslint] eslint is not a constructor
[swintransformer source code reading II] window attention and shifted window attention
What is the difference between these two sets of code?
Promise实例如何解决地狱回调
F - Jealous Two-二维逆序对
[high number] high number plane solid geometry
Activiti启报错: Cannot create PoolableConnectionFactory (Could not create connection to database server
express搭建一个简易的本地后台(一)
Regular expressions for positive and negative values