Interface Future<V>

    • Method Detail

      • isSuccess

        boolean isSuccess()
        Returns true if and only if the operation was completed successfully.
      • cause

        Throwable cause()
        Returns the cause of the failed operation if the operation has failed.
        Returns:
        the cause of the failure. null if succeeded or this future is not completed yet.
      • addListener

        Future<V> addListener​(FutureListener<? extends Future<? super V>> listener)
        Adds the specified listener to this future. The specified listener is notified when this future is done. If this future is already completed, the specified listener is notified immediately.
      • removeListener

        Future<V> removeListener​(FutureListener<? extends Future<? super V>> listener)
        Removes the first occurrence of the specified listener from this future. The specified listener is no longer notified when this future is done. If the specified listener is not associated with this future, this method does nothing and returns silently.
      • await

        boolean await​(long timeout,
                      TimeUnit unit)
               throws InterruptedException
        Waits for this future to be completed within the specified time limit.
        Returns:
        true if and only if the future was completed within the specified time limit
        Throws:
        InterruptedException - if the current thread was interrupted
      • getNow

        V getNow()
        Return the result without blocking. If the future is not done yet this will return null.

        As it is possible that a null value is used to mark the future as successful you also need to check if the future is really done with Future.isDone() and not relay on the returned null value.