@Override
    public ClientResponse get(long timeout, TimeUnit unit) throws InterruptedException,
            ExecutionException, TimeoutException {
        if (!this.latch.await(timeout, unit)) {
            this.status.compareAndSet(STATUS_RUNNING, STATUS_TIMEOUT);
            throw new TimeoutException();
        }
        if (isCancelled()) {
            throw new CancellationException();
        } else if (this.response.getStatus() != ClientResponse.SUCCESS) {
            this.status.compareAndSet(STATUS_RUNNING, STATUS_FAILURE);
            throw new ExecutionException(new Exception(response.getStatusString()));
        } else {
            this.status.compareAndSet(STATUS_RUNNING, STATUS_SUCCESS);
            return this.response;
        }
    }
@ Override public ClientResponse get ( long timeout , TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { if ( ! this . latch . await ( timeout , unit ) ) { this . status . compareAndSet ( STATUS_RUNNING , STATUS_TIMEOUT ) ; throw new TimeoutException ( ) ; } if ( isCancelled ( ) ) { throw new CancellationException ( ) ; } else if ( this . response . getStatus ( ) != ClientResponse . SUCCESS ) { this . status . compareAndSet ( STATUS_RUNNING , STATUS_FAILURE ) ; throw new ExecutionException ( new Exception ( response . getStatusString ( ) ) ) ; } else { this . status . compareAndSet ( STATUS_RUNNING , STATUS_SUCCESS ) ; return this . response ; } }
Waits if necessary for at most the given time for the computation to complete, and then
retrieves its result, if available.

@param timeout
the maximum time to wait.
@param unit
the time unit of the timeout argument .
@return the computed result.
@throws CancellationException
if the computation was cancelled.
@throws ExecutionException
if the computation threw an exception.
@throws InterruptedException
if the current thread was interrupted while waiting.
@throws TimeoutException
if the wait timed out