How to use the Guava ListenableFuture and the Futures.chain() methods

后端 未结 3 1172
南方客
南方客 2021-01-13 22:10

I have a homework task that requires me to learn how to use the Guava concurrency library.

In the task I have several thread pools, where each one is controlled by a

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 22:52

    You might be interested in reading the presentation slides on Guava util.concurrent, linked on the Guava homepage (slide 11 and onward). They really helped me crystallize my understanding of ListenableFuture and why it's so useful.

    My guess is that the goal of your assignment is to understand how Futures work, and how Guava's ListenableFuture and Futures.chain() simplifies their use when coordinating multiple tasks.

    The only open source code that comes to mind that uses ListenableFuture is sitebricks-mail:

    • MailClient interface
    • NettyImapClient implementation

    I don't know if it uses Futures.chain(), though.

提交回复
热议问题