Class FutureUtils


  • public class FutureUtils
    extends Object
    • Constructor Detail

      • FutureUtils

        public FutureUtils()
    • Method Detail

      • cancel

        public static boolean cancel​(@Nullable
                                     Future<?> toCancel)
        Cancel execution of this future without interrupting a running thread. See Future.cancel(boolean) for details.
        Parameters:
        toCancel - the future to cancel
        Returns:
        false if the future could not be cancelled, otherwise true
      • get

        public static <T> T get​(Future<T> future)
        Calls Future.get() without the checked exceptions.
        Type Parameters:
        T - the type returned
        Parameters:
        future - to dereference
        Returns:
        the value of the future
      • get

        public static <T> T get​(Future<T> future,
                                long timeout,
                                TimeUnit unit)
        Calls Future.get(long, TimeUnit) without the checked exceptions.
        Type Parameters:
        T - the type returned
        Parameters:
        future - to dereference
        timeout - to wait
        unit - for timeout
        Returns:
        the value of the future