java - CompletedStage.completedFuture VS CompletedStage.completedStage
问题描述
我看到 Java9 CompletedStage.completedStage() 几乎等于 CompletedStage.ompletedFuture()
当我们必须返回时
CompletionStage<Void>
我们可以同时返回。CompletedFuture.completedFuture() 未被弃用,并且在 CompletedStage() 的 Java 文档中写入
Returns a new CompletionStage that is already completed with the given value and supports only
those methods in interface CompletionStage.
那么真正的区别是什么,什么时候必须使用一个而不是另一个?什么时候必须返回 Void 比较好?
CompletedFuture.completedFuture(null)
或者
CompletedFuture.completedStage(null)
解决方案
推荐阅读
- mysql - 从 csv 文件导入数据库,utf8 问题
- php - jquery-uniform 单选按钮不起作用 yajra-laravel-datatable 包(laravel 5.6)
- jquery - Dropzone jquery - 始终使用 GET 请求,事件设置为 POST
- angular - 使用 angular5 在验证中未收到错误消息
- assembly - IAR 汇编器指令 IF
- python - 在 Python 2.7.1 中创建 unicode XML 文件
- javascript - 当用户完成输入时运行 JS 代码
- asp.net-mvc - ASP.NET MVC 5,在 Session 中存储列表值
- node.js - Firebase 云功能脚本未运行
- android - Apache Cordova 在 div 中加载外部 URL 或网站