Code example for CountDownLatch

Methods: await

0
   * Returns the round trip time for this ping in nanoseconds, or -1 if the 
   * response was cancelled, or -2 if the timeout elapsed before the round 
   * trip completed. 
   */ 
  public long roundTripTime(long timeout, TimeUnit unit) throws InterruptedException {
    if (latch.await(timeout, unit)) {
      return received - sent;
    } else { 
      return -2; 
    } 
  } 
}