public void waitDone ( ) throws ResponseTimeoutException , InvalidResponseException { lock . lock ( ) ; try { if ( ! isDoneResponse ( ) ) { try { condition . await ( timeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new RuntimeException ( "Interrupted" ) ; } } if ( illegalResponseException != null ) { throw illegalResponseException ; } if ( ! isDoneResponse ( ) ) { throw new ResponseTimeoutException ( "No response after " + timeout + " millis" ) ; } } finally { lock . unlock ( ) ; } }
Wait until response received or timeout already reached .