当前位置:网站首页>ReentrantLock学习之---基本属性
ReentrantLock学习之---基本属性
2022-07-26 18:05:00 【virtuousOne】
通过简易的模仿公平锁后,对ReentrantLock的源码进行了学习。
先对节点Node的属性进行了解。
// 枚举: 共享模式
static final Node SHARED = new Node();
// 枚举: 独占模式
static final Node EXCLUSIVE = null;
// 表示当前节点处于 取消状态
static final int CANCELLED = 1;
// 表示当前节点需要唤醒的 后继节点
static final int SIGNAL = -1;
waitStatus主要是通过状态判断节点
// node转台, 可选值 (0,SINGAL -1 ,CANCELLED 1
// 0: 默认状态
// >0 取消状态
// == -1 ,表示当前node如果是head节点时,释放锁之后,需要唤醒他的后继节点
volatile int waitStatus;
// 因为node需要构建成 fifo队列, 所以 prev 指向前继节点
volatile Node prev;
// 因为node需要构建成 fifo队列, 所以 next 指向后继节点
volatile Node next;
// 当前线程
volatile Thread thread;
// 头结点 任何时候,头结点对应的线程都是当前持锁线程
private transient volatile Node head;
//阻塞队列尾结点,
private transient volatile Node tail;
// 表示资源
// 独占锁模式:0 未加锁状态 >0 表示已经加过锁状态
private volatile int state;
// 独占模式下:表示当前持有锁的线程
private transient Thread exclusiveOwnerThread;
边栏推荐
- .net CLR GC dynamic loading transient heap threshold calculation and threshold excess calculation
- Covos: no need to decode! Semi supervised Vos acceleration using motion vectors and residuals of compressed video bitstreams (CVPR 2022)
- Zbxtable 2.0 heavy release! 6 major optimization functions!
- This section is used to supplement 3
- MySQL learning notes -2. how to improve the query performance of SQL statements
- 2022年化工自动化控制仪表考题模拟考试平台操作
- Multi merchant mall system function disassembly Lecture 16 - platform side member growth value record
- 2022 cloud store joint marketing development fund (MDF) Introduction
- Kubectl common commands and simple explanations
- Microsoft silently donated $10000 to curl, which was not notified until half a year later
猜你喜欢

5款WPS Office最佳海外替代品

项目中@RequestMapping的作用以及如何使用

FTP协议

Operations research 69 | explanation of classic examples of dynamic planning

2022上海市安全员C证操作证考试题库模拟考试平台操作

I'm cool, so I'm here

自动化测试的使用场景

SSM integration - functional module and interface testing

Likeshop takeout order system is open source, 100% open source, no encryption

VPC nat (Sant, nant) experiment
随机推荐
2022 tea master (intermediate) examination question simulation examination question bank and answers
Briefly describe the 11 core functional modules of MES system
2022t elevator repair examination questions and online simulation examination
The United States, Japan and South Korea jointly developed 6G with the intention of anti surpassing, but China has long been prepared
(ICLR-2022)TADA!用于视频理解的时间自适应卷积
Likeshop takeout order system is open source, 100% open source, no encryption
如何成为一名优秀的测试/开发程序员?专注谋定而后动......
JS uses readLine to realize terminal input data
[AUTOSAR RTE] - 1-talk about RTE (run time environment)
2022年焊工(初级)操作证考试题库及模拟考试
Verification palindrome string II of leetcode simple question
Huawei cloud · cloud sharing experts~
Kubectl common commands and simple explanations
likeshop外卖点餐系统开源啦100%开源无加密
Sentinel 隔离与降级
Mongodb stats counts the space occupied by the collection
详细介绍@GetMapping和@PostMapping的区别
Sentinel isolation and degradation
NFT digital collection system development: fellow uncle first promoted the blessing series digital collection, which will be sold out immediately
[swoole series 3.1] have you been asked about processes, threads, and collaborations during the interview?