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();
        }
    }
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.

@throws ResponseTimeoutException if timeout reached.
@throws InvalidResponseException if received invalid response.