【发布时间】:2013-11-29 12:17:44
【问题描述】:
我有一个返回 Future 的调用。 但是,我需要打 n 个电话,所以我会得到 n 个期货。我想知道在继续之前如何让期货全部解决(不阻塞服务器)
例如,
while(counter < numCalls){
val future = call(counter)
future.map{ x =>
//do stuff
}
counter += 1
}
//Now I want to execute code here after ALL the futures are resolved without
//blocking the server
【问题讨论】:
-
您可以将 for ... yield 与期货结合使用
标签: scala playframework-2.0 future