@ Override public synchronized Response get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { long now = System . currentTimeMillis ( ) ; long mills = unit . toMillis ( timeout ) ; long toWait = mills ; if ( this . completed ) { return this . getResult ( ) ; } else if ( toWait <= 0 ) { throw new TimeoutException ( "Timeout is smaller than 0." ) ; } else { for ( ; ; ) { wait ( toWait ) ; if ( this . completed ) { return this . getResult ( ) ; } long gap = System . currentTimeMillis ( ) - now ; toWait = toWait - gap ; if ( toWait <= 0 ) { throw new TimeoutException ( ) ; } } } }
Get the Directory Request Response .