code: public R get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
          boolean isTimeOut = !latch.await(timeout, unit);
          try {
              lock.lock();
              if (!isTimeOut) {
                  if (isCancelled) {
                      throw new CancellationException();
                  }
                  else if (failure != null) {
                      throw new ExecutionException(failure);
                  }
  
                  return result;
              }
              else {
                  throw new TimeoutException();
              }
          }
          finally {
              lock.unlock();
          }
      }
docs: {@inheritDoc}