当前位置:网站首页>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;
边栏推荐
- js map使用
- 2022年制冷与空调设备运行操作考试模拟100题及模拟考试
- Mongodb stats counts the space occupied by the collection
- MySQL - 多表查询与案例详解
- (ICLR-2022)TADA!用于视频理解的时间自适应卷积
- Database expansion can also be so smooth, MySQL 100 billion level data production environment expansion practice
- NFT digital collection system development: fellow uncle first promoted the blessing series digital collection, which will be sold out immediately
- 2022年化工自动化控制仪表考题模拟考试平台操作
- MySQL学习笔记-2.如何提高sql语句的查询性能
- 2022 welder (elementary) operation certificate examination question bank and simulation examination
猜你喜欢

2022 chemical automation control instrument test question simulation test platform operation

我酷故我在
![[soft exam] soft exam tutorial + real questions over the years](/img/91/72cdea3eb3f61315595330d2c9016d.png)
[soft exam] soft exam tutorial + real questions over the years

Covos: no need to decode! Semi supervised Vos acceleration using motion vectors and residuals of compressed video bitstreams (CVPR 2022)

深度学习的数学基础

从6月25日考试之后,看新考纲如何复习PMP

2022年化工自动化控制仪表考题模拟考试平台操作

Simulated 100 questions and simulated examination of refrigeration and air conditioning equipment operation examination in 2022

Arrangement of information security emergency plan

2022G1工业锅炉司炉上岗证题库及模拟考试
随机推荐
MySQL - 多表查询与案例详解
[interview question] 1384- share 44 JS problems. Half right is a master
Introduction to Seata
2022年流动式起重机司机考试试题模拟考试平台操作
Verification palindrome string II of leetcode simple question
FTP protocol
The diagram of user login verification process is well written!
How to become an excellent test / development programmer? Focus on planning and then move
SSM integration configuration
如何成为一名优秀的测试/开发程序员?专注谋定而后动......
VPC nat (Sant, nant) experiment
2022 tea master (intermediate) examination question simulation examination question bank and answers
In this competition, you who can understand the topic have great potential
篇7:exited on DESKTOP-DFF5KIK with error code -1073741511.
中信建投启牛会员优惠开户安全吗,不知道是不是最低的佣金
2022年制冷与空调设备运行操作考试模拟100题及模拟考试
Write a starter
Article 7:exited on desktop-dff5kik with error code -1073741511
MySQL - 函数及约束命令
Leetcode simple question: the minimum total time required to fill a cup