AQS结构剖析
2021-04-14 22:30:59 0 举报
AbstractQueuedSynchronizer类从public方法到private方法结构功能分析
作者其他创作
大纲/内容
tryAcquire(arg)独占请求锁
tryRelease(arg)独占释放锁
next
cancelAcquire(node)取消请求锁
tryReleaseShared(arg)共享释放锁
waitStatus
thread
acquireSharedInterruptibly(arg)共享请求锁,中断抛异常
Node
enq(node)队列尾插
addWaiter(node)队列尾插
顶层
队列操作层
抽象API层protected未实现
逻辑控制层private
prev
doAcquireInterruptibly(arg)独占请求锁,中断抛异常
releaseShared(arg)共享释放锁
acquireShared(arg)共享请求锁,不中断
tail
waitStatus=0
doAcquireShared(arg)共享请求锁,不中断
tryAcquireShared(arg)共享请求锁
底层
setHead(node)更新头节点
acquire(arg)独占请求锁,不中断
API层
thread=null
CANCELED = 1SINGAL = -1
public abstract class AbstractQueuedSynchronizer extends AbstractOwnableSynchronizer
doReleaseShared()共享模式释放锁
doAcquireSharedInterruptibly(int arg)共享请求锁,中断抛异常
parkAndCheckInterrupt()park线程
unparkSuccessor(node)唤醒后置节点
acquireInterruptibly(arg)独占请求锁,中断抛异常
release(arg)独占释放锁
isHeldExclusively()当前线程是否独占持有
head
setHeadAndPropagate(Node)更新头节点,共享模式更新广播状态
0 条评论
下一页