public void run() { try { sync.acquireInterruptibly(1); fail("should throw exception"); } catch (InterruptedException success) { } }
/** 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 run() { try { sync.acquireInterruptibly(1); } catch (InterruptedException success) { } }
public void thread2() throws InterruptedException { sync.acquireInterruptibly(1); waitForTick(2); getThread(1).interrupt(); assertTrue(sync.isHeldExclusively()); }
public void realRun() throws InterruptedException { sync.acquireInterruptibly(); }