我怎样才能将未来的未来变成一个未来的对象?

编程入门 行业动态 更新时间:2024-10-13 20:18:46
本文介绍了我怎样才能将未来的未来变成一个未来的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

环境:Akka 2.1,scala 版本 2.10.M6,JDK 1.7,u5

Env: Akka 2.1, scala version 2.10.M6, JDK 1.7,u5

现在是我的问题:我有:

Now is my problem: I have:

future1 = Futures.future(new Callable<Future<object>>(){...}); future2 = ? extends Object; Future.sequence(future1, future2).onComplete(...)

现在在第一行,我有一个 Future 对象的 Future,有没有什么办法可以将它转换成 Future 而不阻塞我当前的线程?

now in first line, I have a future of Future of object, is there any way to convert it into a Future while not blocking my current thread?

akka 有什么方法吗?据我检查,我还没有找到任何......第一次发帖....请注意格式错误并组织... :~P

Is there any method in akka? As far as I checked, I havn't found any yet... First time to have a post....Sry for bad format and organize... :~P

推荐答案

Short answer (English): flatMap dat sh!t

Short answer (English): flatMap dat sh!t

更短的答案(Scala):

Shorter answer (Scala):

flatMap(identity)

最短答案:(Scala 2.12):

Shortest answer: (Scala 2.12):

flatten

长答案(Java):

flatMap(new Mapper<Future<X>>,Future<X>>() { @Override public Future<X> apply(final Future<X> f) { return f; } })

更多推荐

我怎样才能将未来的未来变成一个未来的对象?

本文发布于:2023-11-25 02:25:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627946.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未来   对象

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!