Package org.springframework.util.concurrent

# 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 Summary

Constructors
Constructor
Description
`FutureUtils()`

## Method Summary

Modifier and Type
Method
Description
`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`.
`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`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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:
  - `CompletableFuture.supplyAsync(Supplier)`

### 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:
  - `CompletableFuture.supplyAsync(Supplier, Executor)`