【发布时间】:2023-11-16 06:03:01
【问题描述】:
我最近从 JAVA 8 开始使用 Typescript/Javascript 进行编程。一遇到async/await,它就让我想起了CompletableFuture。在java中,不管方法的返回类型如何,我都可以在方法内部调用someMethodReturningFuture.get(),可以随意阻塞执行。但是在 JavaScript 中,当我们想要使用 await 阻止其他一些异步方法时,为什么我们需要将方法声明为 async?可能是因为Java/CompletableFuture 的问题,我至今仍认为是错误的。
【问题讨论】:
标签: javascript java asynchronous promise completable-future