WaitingThread { public void interrupt() { aborted = true; this.cond.signalAll(); } WaitingThread(Condition cond, RouteSpecificPool pool); final Condition getCondition(); final RouteSpecificPool getPool(); final Thread getThread(); boolean await(Date deadline); void wakeup(); void interrupt();  }
@Test public void testInterrupt() throws InterruptedException { Lock lck = new ReentrantLock(); Condition cnd = lck.newCondition(); WaitingThread wt = new WaitingThread(cnd, null); AwaitThread ath = new AwaitThread(wt, lck, null); ath.start(); Thread.sleep(100); Assert.assertNull("thread caught exception", ath.getException()); Assert.assertTrue("thread not waiting", ath.isWaiting()); Assert.assertEquals("wrong thread", ath, wt.getThread()); ath.interrupt(); Thread.sleep(100); Assert.assertFalse("thread still waiting", ath.isWaiting()); Assert.assertNotNull("thread didn't catch exception", ath.getException()); Assert.assertTrue("thread caught wrong exception", ath.getException() instanceof InterruptedException); Assert.assertNull("thread still there", wt.getThread()); }