Class FutureUtils
java.lang.Object
org.springframework.util.concurrent.FutureUtils
Convenience utilities for working with
Future
and implementations.- Since:
- 6.0
- Author:
- Arjen Poutsma
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<T>
Return a newCompletableFuture
that is asynchronously completed by a task running in theForkJoinPool.commonPool()
with the value obtained by calling the givenCallable
.static <T> CompletableFuture<T>
Return a newCompletableFuture
that is asynchronously completed by a task running in the given executor with the value obtained by calling the givenCallable
.
-
Constructor Details
-
FutureUtils
public FutureUtils()
-
-
Method Details
-
callAsync
Return a newCompletableFuture
that is asynchronously completed by a task running in theForkJoinPool.commonPool()
with the value obtained by calling the givenCallable
.- Parameters:
callable
- a function that returns the value to be used, or throws an exception- Returns:
- the new CompletableFuture
- See Also:
-
callAsync
Return a newCompletableFuture
that is asynchronously completed by a task running in the given executor with the value obtained by calling the givenCallable
.- Parameters:
callable
- a function that returns the value to be used, or throws an exceptionexecutor
- the executor to use for asynchronous execution- Returns:
- the new CompletableFuture
- See Also:
-