当前位置:网站首页>Synchronized and volatile
Synchronized and volatile
2022-07-25 22:10:00 【Not ashamed_】
synchronized keyword , representative This method locks , Equivalent to no matter which thread ( For example, threads A), When running to this method , Check for other threads B( perhaps C、 D etc. ) Using this method ( Or other synchronization methods of this class )
You have to wait for it to be used synchronized Method thread B( perhaps C 、D) Run this method before running this thread A
We learned that synchronized It's blocking synchronization , In case of fierce thread competition, it will be upgraded to heavyweight lock .
and volatile It can be said that java The most lightweight virtual machine Synchronization mechanism
By volatile The decorated variable can ensure that each thread can get the latest value of the variable , Guarantee the data “ visibility ”. So as to avoid data dirty reading .
边栏推荐
- Nuclear power plants strive to maintain safety in the heat wave sweeping Europe
- El expression improves JSP
- Whether the five distribution methods will produce internal fragments and external fragments
- Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
- Imitation Tiktok homepage interface
- 还不懂mock测试?一篇文章带你熟悉mock
- Jmeter---设置代理录制请求
- TFrecord写入与读取
- On the difference between break and continue statements
- [test development methodology] experience of test development platform PK - choice
猜你喜欢

Redis usage details

ansible+Crontab批部署巡检

动画曲线天天用,你能自己整一个吗?看完这篇你就会了!

如何将一个域名解析到多个IP地址?

开源的RSS订阅器FreshRSS

2022 the latest software tests eight part essay. Whether you can offer depends on how you recite it

信息安全建设原则指导

On the difference between break and continue statements

Square root of X

TS:typora代码片段缩进显示异常(已解决)-2022.7.24
随机推荐
synchronized与volatile
[Fantan] how to design a test platform?
Sofa weekly | open source person - Niu Xuewei, QA this week, contributor this week
Imitation Tiktok homepage interface
All you want to know about interface testing is here
Special class design
golang : MVC之models
【汇编语言01】基础知识
Preliminary study on Tesseract OCR
Flex layout
[assembly language 01] basic knowledge
如何快速搭建图片服务器[通俗易懂]
YUV420 yuv420sp image format "recommended collection"
Unity performance optimization direction
6-17漏洞利用-反序列化远程命令执行漏洞
Bitcoin.com:usdd represents a truly decentralized stable currency
Guiding principles of information security construction
internship:普通常用的工具类编写
EL表达式改进JSP
4day