ListenableFutureTask/ExecutorService
我的类路径中有 Guava,并且想要使用 ListenableFuture
,但目前我不知道如何提交 ListenableFuture
,或者目前只能在不使用的情况下使用它们调用线程中的执行程序?我读到 r10 中有一个装饰器,但尚未推出?
我找到了 Futures.makeListenable(Future
但我不确定这是否是目前使用 ListenableFuture
的唯一方法。
亲切的问候,
约翰内斯
I've Guava in my Classpath and want to use ListenableFuture
s, but currently I don't know how to submit ListenableFuture
s or is it currently only possible to use them without an executor in the calling thread? I've read that a decorator is available in r10 which isn't out?
I've found Futures.makeListenable(Future<V> future)
but I'm not sure if that's currently the only way how to use ListenableFuture
s.
kind regards,
Johannes
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们改进了即将发布的 r10 的
ListenableFuture
Javadoc,包括添加有关如何获取类实例的信息。您可以在此处查看 HEAD 版本:http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/ListenableFuture.html您感兴趣的装饰器方法是 MoreExecutors.listeningDecorator
We improved the
ListenableFuture
Javadoc for the forthcoming r10, including adding information about how to obtain an instance of the class. You can see the HEAD version here: http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/util/concurrent/ListenableFuture.htmlThe decorator method you're interested in is MoreExecutors.listeningDecorator