当前位置:网站首页>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 .
边栏推荐
- 面对AI人才培养的“产学研”鸿沟,昇腾AI如何做厚产业人才黑土地?
- A3.ansible production practice case -- system initialization roles
- Research and Analysis on the status quo of China's Cross lamp market and forecast report on its development prospect (2022)
- Programmer weekly (issue 4): the wealth view of programmers
- Raspberry PI (bullseye) replacement method of Alibaba cloud source
- Mastering quantization technology is the key to video compression
- Is there any risk for CICC fortune to open an account? Is it safe to open an account?
- Huasheng lithium battery IPO meeting: 9-month revenue of 690million; shenjinliang's family relationship is complex
- 2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
- Flutter 网络请求封装之Dio(Cookie管理、添加拦截器、下载文件、异常处理、取消请求等)
猜你喜欢
Oracle case: does index range scan really not read multiple blocks?
Obsidian基础教程
Pycharm 2022.1 EAP 2 release
用idea建立第一個網站
Evaluate the generalization performance of models and build integrated models using out of pocket prediction (oof)
2022-2028 global carbon fiber unidirectional tape industry research and trend analysis report
2022-2028 global horizontal reciprocating compressor industry research and trend analysis report
Privatization lightweight continuous integration deployment scheme -- 03 deployment of Web services (Part 2)
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
Nacos 源码分析01 代码结构
随机推荐
HotSpot JVM 「01」类加载、链接和初始化
Devops之制品库平台nexus实践
MySQL modifies multiple tables and adds multiple fields through SQL
Lecture 14 of the Blue Bridge Cup -- number theory [example]
Obsidian basic tutorial
Some websites used by Beijing University of technology when graduating
Research and Analysis on the status quo of China's Cross lamp market and forecast report on its development prospect (2022)
A3.ansible production practice case -- system initialization roles
Mastering quantization technology is the key to video compression
Did you really learn the right game modeling with 3DMAX?
Open source optimized VVC encoder in general scenarios
Talk about adapter mode
Various special effect cases of Experiment 3
2022giao考游记
Beyond natural motion: exploring the discontinuity of video interpolation
Market demand analysis and investment prospect research report of China's CNC machine tool industry 2022-2028
Report on development status and prospects of global and Chinese coating industry strategic planning proposal 2022-2028
What is a code baseline?
Travel notes of 2022giao
This 110 year old "longevity" enterprise has been planning for the next century