直接使用Spring @Async与CompleteableFuture有什么优势?

直接使用Spring @Async与CompleteableFuture有什么优势?,第1张

直接使用Spring @Async与CompleteableFuture有什么优势?

您的应用程序容器管理。由于不建议

Thread
您自己生成,因此可以让容器注入Managed
Executor

@Serviceclass MyService {  @Autowired  private Executor executor;  public CompletableFuture<?> compute() {    return CompletableFuture.supplyAsync(() -> , executor);  }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5439461.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存