Scala:在其他期货完成时完成期货 [英] Scala: completing a Future when other Futures are completed

查看:72
本文介绍了Scala:在其他期货完成时完成期货的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我引用了n个Future实例f1,.....fn.是否可以使用Future.apply创建仅在n个Future中的至少一个完成时才执行的Future,而无需不断检查其完成状态,而是通过更有效的方式(也许是回调)来完成?

I have references to n Future instances f1,.....fn. Is it possible to use Future.apply to create a Future that would complete only when at least one of the n Futures completes, without constantly checking their completion status, but instead by some more efficient way, maybe a callback?

推荐答案

Future.firstCompletedOf(Seq(f1, ..., fn))

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆