mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
Update reentrantlock.md
This commit is contained in:
parent
5b97792e62
commit
2be829c35a
@ -167,7 +167,7 @@ AQS使用一个Volatile的int类型的成员变量来表示同步状态,通过
|
|||||||
waitStatus 有下面几个枚举值:
|
waitStatus 有下面几个枚举值:
|
||||||
|
|
||||||
| 枚举 | 含义 |
|
| 枚举 | 含义 |
|
||||||
| :-------- | :--------------------------------------------- |
|
| :-------- | :----------------------------------------------- |
|
||||||
| 0 | 当一个 Node 被初始化的时候的默认值 |
|
| 0 | 当一个 Node 被初始化的时候的默认值 |
|
||||||
| CANCELLED | 为 1,表示线程获取锁的请求已经取消了 |
|
| CANCELLED | 为 1,表示线程获取锁的请求已经取消了 |
|
||||||
| CONDITION | 为-2,表示节点在等待队列中,节点线程等待唤醒 |
|
| CONDITION | 为-2,表示节点在等待队列中,节点线程等待唤醒 |
|
||||||
@ -187,7 +187,7 @@ private volatile int state;
|
|||||||
下面提供了几个访问这个字段的方法:
|
下面提供了几个访问这个字段的方法:
|
||||||
|
|
||||||
| 方法名 | 描述 |
|
| 方法名 | 描述 |
|
||||||
| :----------------------------------------------------------- | :------------------- |
|
| :----------------------------------------------------------- | :---------------------- |
|
||||||
| protected final int getState() | 获取 State 的值 |
|
| protected final int getState() | 获取 State 的值 |
|
||||||
| protected final void setState(int newState) | 设置 State 的值 |
|
| protected final void setState(int newState) | 设置 State 的值 |
|
||||||
| protected final boolean compareAndSetState(int expect, int update) | 使用 CAS 方式更新 State |
|
| protected final boolean compareAndSetState(int expect, int update) | 使用 CAS 方式更新 State |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user