Christian Bongiorno :
What's the advantage of using Spring Async vs. Just returning the CompletableFuture
on your own?
Flown :
Your application is managed by the container. Since it's discouraged to spawn Thread
s on you own, you can let the container inject a managed Executor
.
@Service
class MyService {
@Autowired
private Executor executor;
public CompletableFuture<?> compute() {
return CompletableFuture.supplyAsync(() -> /* compute value */, executor);
}
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=434611&siteId=1