public void thread2() throws InterruptedException { waitForTick(1); getThread(1).interrupt(); sync.acquire(1); c.signal(); sync.release(1); }
public void thread1() throws InterruptedException { sync.acquire(1); assertFalse(sync.hasWaiters(c)); assertEquals(0, sync.getWaitQueueLength(c)); c.await(); assertTick(1); sync.release(1); }
public void thread2() throws InterruptedException { waitForTick(1); sync.acquire(1); c.signal(); sync.release(1); getThread(1).join(SHORT_DELAY_MS); assertFalse(getThread(1).isAlive()); }
public void thread2() throws InterruptedException { waitForTick(2); sync.acquire(1); assertFalse(sync.getWaitingThreads(c).isEmpty()); c.await(); assertTick(3); sync.release(1); }
public void thread1() { try { sync.acquire(1); c.awaitNanos(1000 * 1000 * 1000); // 1 sec sync.release(1); fail("should throw exception"); } catch (InterruptedException success) { assertTick(1); } }
public void thread2() throws InterruptedException { waitForTick(1); sync.acquire(1); assertTrue(sync.hasWaiters(c)); assertEquals(1, sync.getWaitQueueLength(c)); c.await(); assertTick(2); sync.release(1); }
public void thread1() { try { sync.acquire(1); java.util.Date d = new java.util.Date(); c.awaitUntil(new java.util.Date(d.getTime() + 10000)); sync.release(1); fail("should throw exception"); } catch (InterruptedException success) { assertTick(1); } }
public void thread3() { waitForTick(2); sync.acquire(1); assertTrue(sync.hasWaiters(c)); assertEquals(2, sync.getWaitQueueLength(c)); c.signalAll(); sync.release(1); waitForTick(3); sync.acquire(1); assertFalse(sync.hasWaiters(c)); assertEquals(0, sync.getWaitQueueLength(c)); sync.release(1); }
public void thread2() throws InterruptedException { waitForTick(1); sync.acquire(1); assertTrue(sync.hasWaiters(c)); assertEquals(1, sync.getWaitQueueLength(c)); c.signal(); sync.release(1); waitForTick(2); sync.acquire(1); assertFalse(sync.hasWaiters(c)); assertEquals(0, sync.getWaitQueueLength(c)); sync.release(1); getThread(1).join(SHORT_DELAY_MS); assertFalse(getThread(1).isAlive()); }
public void thread3() { sync.acquire(1); assertTrue(sync.getWaitingThreads(c).isEmpty()); sync.release(1); waitForTick(3); sync.acquire(1); assertTrue(sync.hasWaiters(c)); assertTrue(sync.getWaitingThreads(c).contains(getThread(1))); assertTrue(sync.getWaitingThreads(c).contains(getThread(2))); c.signalAll(); sync.release(1); waitForTick(4); sync.acquire(1); assertFalse(sync.hasWaiters(c)); assertTrue(sync.getWaitingThreads(c).isEmpty()); sync.release(1); }
public void thread3() { waitForTick(1); sync.acquire(1); c.signalAll(); sync.release(1); }
public void thread2() throws InterruptedException { sync.acquire(1); c.await(); assertTick(1); sync.release(1); }