
1 lhx2008 2020-04-12 17:56:06 +08:00 via Android 应该是说说 AQS 的东西 |
2 tcxurun 2020-04-12 18:49:32 +08:00 Reentrantlock 主要是基于 AQS,而 AQS 继承一个抽象类 AbstractOwnableSynchronizer,有个变量 exclusiveOwnerThread,用来存储锁持有的线程,然后比较,比如源码中你会看到这个 (current == getExclusiveOwnerThread()) |
3 coer 2020-04-12 19:39:40 +08:00 从 lock()进去走几步就能看到 nonfairTryAcquire(int acquires)中的 else if (current == getExclusiveOwnerThread())..... |