【发布时间】:2018-04-23 16:54:34
【问题描述】:
在 Scala 和其他编程语言中,可以使用 Futures 和 Await。
(在实际代码中,人们会使用例如 zip+map 而不是 Await)
def b1() = Future { 1 }
def b2() = Future { 2 }
def a() = Future {
Await.result(b1(),Duration.inf) + Await.result(b2(),Duration.inf)
}
与 Javascript/Scala 中的 Async/Await 有什么区别?
async function b1() { return 1 }
async function b2() { return 3 }
async function a() {
return await b1() + await b2()
}
【问题讨论】:
标签: scala async-await future