AbstractQueuedSynchronizer extends AbstractOwnableSynchronizer implements java.io.Serializable { protected final long getState() { return state; } protected  AbstractQueuedSynchronizer(); final void acquire(long arg); final void acquireInterruptibly(long arg); final boolean tryAcquireNanos(long arg, long nanosTimeout); final boolean release(long arg); final void acquireShared(long arg); final void acquireSharedInterruptibly(long arg); final boolean tryAcquireSharedNanos(long arg, long nanosTimeout); final boolean releaseShared(long arg); final boolean hasQueuedThreads(); final boolean hasContended(); final Thread getFirstQueuedThread(); final boolean isQueued(Thread thread); final boolean hasQueuedPredecessors(); final int getQueueLength(); final Collection<Thread> getQueuedThreads(); final Collection<Thread> getExclusiveQueuedThreads(); final Collection<Thread> getSharedQueuedThreads(); String toString(); final boolean owns(ConditionObject condition); final boolean hasWaiters(ConditionObject condition); final int getWaitQueueLength(ConditionObject condition); final Collection<Thread> getWaitingThreads(ConditionObject condition);  }
@Test public void testGetState() { final Mutex sync = new Mutex(); sync.acquire(); assertTrue(sync.isHeldExclusively()); sync.release(); assertFalse(sync.isHeldExclusively()); final BooleanLatch acquired = new BooleanLatch(); final BooleanLatch done = new BooleanLatch(); Thread t = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { sync.acquire(); assertTrue(acquired.releaseShared(0)); done.acquireShared(0); sync.release(); }}); acquired.acquireShared(0); assertTrue(sync.isHeldExclusively()); assertTrue(done.releaseShared(0)); awaitTermination(t); assertFalse(sync.isHeldExclusively()); }