Skip to content

Commit

Permalink
Update aqs.md
Browse files Browse the repository at this point in the history
最后分析UnparkSuccessor()源码时的注释 `// 等待队列中所有还有用的结点,都向前移动` 疑似不太对,更准确地注释应该为:`// 从尾部开始倒着寻找第一个还未取消的节点(真正的后继者)`(这也是参考源码的英文注解),原来的解释比较迷惑。
  • Loading branch information
arglone committed Nov 19, 2022
1 parent e36a52c commit d4a6735
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/thread/aqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ private void unparkSuccessor(Node node) {
// 得到头结点的后继结点head.next
Node s = node.next;
// 如果这个后继结点为空或者状态大于0
// 通过前面的定义我们知道,大于0只有一种可能,就是这个结点已被取消
// 通过前面的定义我们知道,大于0只有一种可能,就是这个结点已被取消(只有 Node.CANCELLED(=1) 这一种状态大于0)
if (s == null || s.waitStatus > 0) {
s = null;
// 等待队列中所有还有用的结点,都向前移动
// 从尾部开始倒着寻找第一个还未取消的节点(真正的后继者)
for (Node t = tail; t != null && t != node; t = t.prev)
if (t.waitStatus <= 0)
s = t;
Expand Down

0 comments on commit d4a6735

Please sign in to comment.