Class FutureUtils

java.lang.Object
org.springframework.util.concurrent.FutureUtils

public abstract class FutureUtils extends Object
Convenience utilities for working with Future and implementations.
Since:
6.0
Author:
Arjen Poutsma
  • Constructor Details

    • FutureUtils

      public FutureUtils()
  • Method Details

    • callAsync

      public static <T> CompletableFuture<T> callAsync(Callable<T> callable)
      Return a new CompletableFuture that is asynchronously completed by a task running in the ForkJoinPool.commonPool() with the value obtained by calling the given Callable.
      Parameters:
      callable - a function that returns the value to be used, or throws an exception
      Returns:
      the new CompletableFuture
      See Also:
    • callAsync

      public static <T> CompletableFuture<T> callAsync(Callable<T> callable, Executor executor)
      Return a new CompletableFuture that is asynchronously completed by a task running in the given executor with the value obtained by calling the given Callable.
      Parameters:
      callable - a function that returns the value to be used, or throws an exception
      executor - the executor to use for asynchronous execution
      Returns:
      the new CompletableFuture
      See Also: