/** acquireInterruptibly succeeds when released, else is interruptible */ public void testAcquireInterruptibly() throws InterruptedException { final Mutex sync = new Mutex(); final BooleanLatch threadStarted = new BooleanLatch(); sync.acquireInterruptibly(); Thread t = newStartedThread( new CheckedInterruptedRunnable() { public void realRun() throws InterruptedException { assertTrue(threadStarted.releaseShared(0)); sync.acquireInterruptibly(); } }); threadStarted.acquireShared(0); waitForQueuedThread(sync, t); t.interrupt(); awaitTermination(t); assertTrue(sync.isHeldExclusively()); }
public void realRun() throws InterruptedException { sync.acquireInterruptibly(); }