/** Awaits condition using the specified AwaitMethod. */
 void await(ConditionObject c, AwaitMethod awaitMethod) throws InterruptedException {
   long timeoutMillis = 2 * LONG_DELAY_MS;
   switch (awaitMethod) {
     case await:
       c.await();
       break;
     case awaitTimed:
       assertTrue(c.await(timeoutMillis, MILLISECONDS));
       break;
     case awaitNanos:
       long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
       long nanosRemaining = c.awaitNanos(nanosTimeout);
       assertTrue(nanosRemaining > 0);
       break;
     case awaitUntil:
       assertTrue(c.awaitUntil(delayedDate(timeoutMillis)));
       break;
   }
 }
 /** Checks that awaiting the given condition times out (using the default timeout duration). */
 void assertAwaitTimesOut(ConditionObject c, AwaitMethod awaitMethod) {
   long timeoutMillis = timeoutMillis();
   long startTime = System.nanoTime();
   try {
     switch (awaitMethod) {
       case awaitTimed:
         assertFalse(c.await(timeoutMillis, MILLISECONDS));
         break;
       case awaitNanos:
         long nanosTimeout = MILLISECONDS.toNanos(timeoutMillis);
         long nanosRemaining = c.awaitNanos(nanosTimeout);
         assertTrue(nanosRemaining <= 0);
         break;
       case awaitUntil:
         assertFalse(c.awaitUntil(delayedDate(timeoutMillis)));
         break;
       default:
         throw new UnsupportedOperationException();
     }
   } catch (InterruptedException ie) {
     threadUnexpectedException(ie);
   }
   assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
 }