当前位置:网站首页>The difference between synchronize and volatile
The difference between synchronize and volatile
2022-06-25 22:39:00 【No trace after wind 2018】
synchronize and volatile The difference between
volatile Can only be used to decorate variables ,synchronize Can be used to modify methods 、 Code block . With jdk Technological development ,synchronize The implementation efficiency will be greatly improved , therefore synchronize It is still common in the project process ;
Multithreaded access volatile There will be no blockage ; and synchronize There will be a blockage ;
volatile It can ensure the synchronization of variables between private memory and main memory , But the atomicity of variables cannot be guaranteed ;synchronize Variable atomicity can be guaranteed ;
volatile Is the visibility of variables between threads ;synchronize Is the synchronization of accessing resources between multiple threads ;
about volatile Decorated variable , It can solve the visibility problem of variable reading , There is no guarantee of atomicity . For multiple threads accessing the same instance variable, lock synchronization is still required .
边栏推荐
- Analysis of China's tractor manufacturing and operation situation and forecast report of prospect trend 2022-2028
- [HNU summer semester] preparation stage of database system design
- 聊聊Adapter模式
- Nacos source code analysis 01 code structure
- Simple record of fire & spell effects
- 2022-2028 global TFT LCD touch screen industry research and trend analysis report
- Conglin environmental protection IPO meeting: annual profit of more than 200million to raise 2.03 billion
- This 110 year old "longevity" enterprise has been planning for the next century
- Tiger DAO VC产品正式上线,Seektiger生态的有力补充
- Introduction to HNU database system ODBC
猜你喜欢

HNU network counting experiment: experiment I application protocol and packet analysis experiment (using Wireshark)

Introduction to HNU database system ODBC

【WPF】CAD工程图纸转WPF可直接使用的xaml代码技巧

图解栈帧运行过程

Processing of limit operator in Presto

Nacos 源码分析01 代码结构
Interview shock 23: talk about thread life cycle and transformation process?

Win11 start menu right click blank? The right button of win11 start menu does not respond. Solution

2022-2028 global web and browser isolation platform industry research and trend analysis report

2022-2028 global vacuum jacket system industry survey and trend analysis report
随机推荐
目前期货怎么开户安全些?哪些期货公司靠谱些?
圖解棧幀運行過程
[proteus simulation] Arduino uno pattern water lamp
Analysis report on scale investigation and investment development suggestions of China's special equipment inspection and testing industry 2022-2028
面对AI人才培养的“产学研”鸿沟,昇腾AI如何做厚产业人才黑土地?
leetcode: 49. Grouping of alphabetic words
Open source optimized VVC encoder in general scenarios
2022-2028 global variable frequency compressor technology industry research and trend analysis report
Application runtime layotto enters CNCF cloud native panorama
Simple record of fire & spell effects
Is it safe to open an account with Caicai securities?
EVC, VVC, lcevc test: how about the performance of the latest MPEG codec?
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
27 Chinese scholars including Yaoban and chendanqi from Tsinghua won the awards, and the list of winners of Sloan award in 2022 was issued
2022-2028 global web and browser isolation platform industry research and trend analysis report
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
Obsidian basic tutorial
2022-2028 global proton exchange membrane hydrogen electrolyzer industry survey and trend analysis report
HNU network counting experiment: Experiment 5 network layer and link layer protocol analysis (packettracer)
Huawei cloud SMS has tested that many mobile phones prompt frequent sending