05 2021 档案
摘要:private final ReentrantLock lock = new ReentrantLock(); private static class Generation { Generation() {} boolean broken; } private Generation generat
阅读全文
摘要:@ReservedStackAccess final boolean tryReadLock() { Thread current = Thread.currentThread(); // 死循环 for (;;) { int c = getState(); // 当前有别的线程持有写锁,此时尝试获
阅读全文
摘要:static final class ThreadLocalHoldCounter extends ThreadLocal<HoldCounter> { public HoldCounter initialValue() { return new HoldCounter(); } } private
阅读全文
摘要:static final class ThreadLocalHoldCounter extends ThreadLocal<HoldCounter> { public HoldCounter initialValue() { return new HoldCounter(); } } private
阅读全文
摘要:// 尝试获取写锁 protected final boolean tryAcquire(int acquires) { Thread current = Thread.currentThread(); int c = getState(); // 全状态 int w = exclusiveCoun
阅读全文
摘要:ReentrantReadWriteLock.Sync的状态为一个32位整数。分为两部分,每部分16位,1~16位为写锁的重入次数,17~32位为读锁的获取次数。
阅读全文
摘要:// ReentrantLock.FairSync::initialTryLock final boolean initialTryLock() { Thread current = Thread.currentThread(); int c = getState(); // c==0说明当前锁无人
阅读全文
摘要:// 尝试释放锁 protected final boolean tryRelease(int releases) { // c:释放锁后的新state int c = getState() - releases; if (getExclusiveOwnerThread() != Thread.cu
阅读全文

浙公网安备 33010602011771号