--- jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2017/07/17 21:01:30 1.57 +++ jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java 2017/09/29 19:34:37 1.58 @@ -34,6 +34,9 @@ public class AbstractQueuedSynchronizerT * methods/features of AbstractQueuedSynchronizer are tested via * other test classes, including those for ReentrantLock, * ReentrantReadWriteLock, and Semaphore. + * + * Unlike the javadoc sample, we don't track owner thread via + * AbstractOwnableSynchronizer methods. */ static class Mutex extends AbstractQueuedSynchronizer { /** An eccentric value for locked synchronizer state. */ @@ -41,18 +44,19 @@ public class AbstractQueuedSynchronizerT static final int UNLOCKED = 0; + /** Owner thread is untracked, so this is really just isLocked(). */ @Override public boolean isHeldExclusively() { int state = getState(); assertTrue(state == UNLOCKED || state == LOCKED); return state == LOCKED; } - @Override public boolean tryAcquire(int acquires) { + @Override protected boolean tryAcquire(int acquires) { assertEquals(LOCKED, acquires); return compareAndSetState(UNLOCKED, LOCKED); } - @Override public boolean tryRelease(int releases) { + @Override protected boolean tryRelease(int releases) { if (getState() != LOCKED) throw new IllegalMonitorStateException(); assertEquals(LOCKED, releases); setState(UNLOCKED); @@ -83,13 +87,14 @@ public class AbstractQueuedSynchronizerT release(LOCKED); } + /** Faux-Implements Lock.newCondition(). */ public ConditionObject newCondition() { return new ConditionObject(); } } /** - * A simple latch class, to test shared mode. + * A minimal latch class, to test shared mode. */ static class BooleanLatch extends AbstractQueuedSynchronizer { public boolean isSignalled() { return getState() != 0; }