刚刚面试官问了这个问题,没答上来,百度也没找到。
|
lhx2008Apr 12, 2020 via Android
1
应该是说说 AQS 的东西
|
|
2
Reentrantlock 主要是基于 AQS,而 AQS 继承一个抽象类 AbstractOwnableSynchronizer,有个变量 exclusiveOwnerThread,用来存储锁持有的线程,然后比较,比如源码中你会看到这个
(current == getExclusiveOwnerThread()) |
|
coerApr 12, 2020
3
从 lock()进去走几步就能看到 nonfairTryAcquire(int acquires)中的 else if (current == getExclusiveOwnerThread()).....
|