Code example for ListenableFuture

Methods: getisDone

0
   * 
   * @return true if the specified future has been resolved without throwing an exception or being 
   *     cancelled. 
   */ 
  public static boolean isSuccess(ListenableFuture<?> future) throws InterruptedException {
    if (!future.isDone()) {
      return false; 
    } 
 
    try { 
      // Try to get the future, but ignore (and preserve) the thread interrupted state. 
      // This should be fast because we know the future is already complete. 
      future.get();
      return true; 
    } catch (ExecutionException e) {
      // The computation threw an exception, so it did not complete successfully. 
      return false; 
    } catch (CancellationException e) {
      // The computation was cancelled, so it did not complete successfully. 
      return false; 
Experience pair programming with AI  Get Codota for Java