AQS类图
2019-12-02 11:22:11 2 举报
AbstractQueuedSynchronizer
作者其他创作
大纲/内容
addWorker
ConditionObject
- firstWaiter: Node- lastWaiter: Node
+ signal(): void+ signalAll(): void+ await(): void
AbstractQueuedSynchronizer
- state: int- tail: Node- head: Node- unsafe: Unsafe- stateOffset: long- headOffset: long- tailOffset: long- waitStatusOffset: long- nextOffset: long
+ acquire(arg: int): void+ tryAcquire(arg: int): boolean+ acquireShared(arg: int): void+ acquireInterruptibly(arg: int): void+ release(arg: int): boolean+ releaseShared(arg: int): boolean+ tryRelease(arg: int): boolean+ tryReleaseShared(arg: int): boolean
next
Node
# SHARED: Node# EXCLUSIVE: Node# CANCELLED: int = 1# SIGNAL: int = -1# CONDITION: int = -2# PROPAGATE: int = -3# waitStatus : int# prev: Node# next: Node# nextWaiter: Node# thread: Thread
+ isShared(): boolean+ predecessor(): Node
生成Node节点
结束
prev
独占式获取同步状态(acquire)流程图
获取同步状态
设置当前节点头结点
tryAcquire
p==head
是
Tail
线程被中断或前驱节点被释放
失败
成功
Head
出列
前驱节点是否为头结点
同步器
入队
线程进入等待状态
否
AbstractOwnableSynchronizer
- exclusiveOwnerThread: Thread
+ setExclusiveOwnerThread(thread:Thread): void+ getExclusiveOwnerThread(): Thread
开始
加入到同步队列
0 条评论
下一页