当前位置:网站首页>The difference between synchronized and lock locks
The difference between synchronized and lock locks
2022-07-24 11:39:00 【yangdachaoa】
1、synchronized yes java keyword ,jvm level ; lock It's a class ;
2、synchronized Unable to get lock status , lock You can get the state of the lock ;
3、synchronized It's an automatic lock , If the code is executed or an exception occurs , He will automatically release the locked resources , lock Manual lock , It needs to be called manually unlock Method to release locked resources , It's usually in finally; If it is not released, a deadlock will occur ;
4、synchronized If the thread a Get the resources of the lock , happening , Threads b Will be waiting , and lock If the locked resource cannot be obtained , The thread ends without waiting ;
5、synchronized It's reentrant 、 Non interruptible , Unfair , lock Reentrant 、 To judge 、 Fair enough ( Both are acceptable );
边栏推荐
- Reprint of illustrations in nature, issue 3 - area map (part2-100)
- Fastcgi operation principle and PHP FPM parameter configuration
- String -- 344. Reverse string
- 6k+ star, a deep learning code base for Xiaobai! One line of code implements all attention mechanisms!
- The third day of hcip mGRE experiment
- cgo+gSoap+onvif学习总结:9、go和c进行socket通信进行onvif协议处理
- Repeated calls, messages, idempotent schemes, full collation
- Stack Title: basic calculator II
- Lanqiao cup provincial training camp - commonly used STL
- Best practice | using Tencent cloud AI character recognition to realize enterprise qualification certificate recognition
猜你喜欢

1184. 公交站间的距离 : 简单模拟题

RRPN:Arbitrary-Oriented Scene Text Detection via Rotation Proposals

有关并行的两个重要定律

2022,软测人的平均薪资,看完我瞬间凉了...

Robot framework official tutorial (I) getting started

String -- 344. Reverse string

Jmeter-If控制器

Linked list - Sword finger offer interview question 02.07. linked list intersection

Reprint of illustrations in nature, issue 3 - area map (part2-100)

C language programming code
随机推荐
[markdown grammar advanced] make your blog more exciting (IV: set font style and color comparison table)
08 [AIO programming]
[golang] golang implements MD5 encryption function
How to use SSH and SFTP protocols at home
[golang] golang implements sha256 encryption function
20000 words detailed explanation, thoroughly understand es!
Sorting out the ideas of data processing received by TCP server, and the note of select: invalid argument error
JVM visualvm: multi hop fault handling tool
Imeta view | is short reading long amplicon sequencing applicable to the prediction of microbiome function?
2022, the average salary of the soft tester, after reading it, I was instantly cool
MOS管 —— 快速复苏应用笔记(壹)[原理篇]
生信周刊第37期
哈希——1. 两数之和——有人白天相爱,有人夜里看海,有人力扣第一题都做不出来
Two important laws about parallelism
Nodejs ctf 基础
Hash - 202. Happy number
Linked list - 142. Ring linked list II
Sentinel vs Hystrix 限流对比,到底怎么选?
[deserialization vulnerability-02] principle test and magic method summary of PHP deserialization vulnerability
运算放大器 —— 快速复苏笔记[壹](参数篇)