当前位置:网站首页>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 .
边栏推荐
- Is it safe to open an account with Caicai securities?
- Introduction to HNU database system ODBC
- Diagram of stack frame running process
- Pycharm 2022.1 EAP 2 release
- Raspberry PI (bullseye) replacement method of Alibaba cloud source
- Tlog helps Pangu framework realize microservice link log tracking
- Research and Analysis on the current situation of Chinese acne drug market and forecast report on its development prospect (2022)
- Jingwei Hengrun is registered through the science and Innovation Board: it plans to raise 5billion yuan, with a 9-month revenue of 2.1 billion yuan
- 聊聊Adapter模式
- Where is win11 screen recording data saved? Win11 screen recording data storage location
猜你喜欢

圖解棧幀運行過程

Simple and easy-to-use cache library gcache

Practice of product library platform nexus of Devops

Programmer weekly (issue 4): the wealth view of programmers

How to use Matplotlib library to realize enlarged display of graphic local data

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

2022-2028 global industrial TFT LCD industry survey and trend analysis report
Evaluate the generalization performance of models and build integrated models using out of pocket prediction (oof)

2022-2028 global horizontal reciprocating compressor industry research and trend analysis report

Where is win11 screen recording data saved? Win11 screen recording data storage location
随机推荐
China bed and mattress market status research analysis and development prospect forecast report (2022)
Processing of limit operator in Presto
Facing the "industry, University and research" gap in AI talent training, how can shengteng AI enrich the black land of industrial talents?
Simple record of fire & spell effects
AbstractFactory Abstract Factory
Analysis of China's tractor manufacturing and operation situation and forecast report of prospect trend 2022-2028
Nacos source code analysis 01 code structure
2022giao考游记
2022-2028 global DC linear variable differential transformer (LVDT) industry survey and trend analysis report
How to use the find command
HotSpot JVM 「01」类加载、链接和初始化
Research and Analysis on the current situation of Chinese acne drug market and forecast report on its development prospect (2022)
HNU network counting experiment: experiment I application protocol and packet analysis experiment (using Wireshark)
STM32F103RCT6
GridView component of swiftui 4 new features (tutorial includes source code)
图解栈帧运行过程
Nacos 源码分析01 代码结构
Simple and easy-to-use cache library gcache
Interview shock 23: talk about thread life cycle and transformation process?
leetcode: 49. Grouping of alphabetic words