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 an individual object.
Each pool has several working threads that perform simple tasks (mostly emulating doing stuff by using Thread.sleep(long)) and all those simple tasks are stored in a container object that emulates a messageboard.
Each simple task has a dependency list of other tasks, and it cannot be executed until all of those tasks are completed.
How can I benefit from the Guava library using the ListenableFuture and the Futures.chain()?
I have searched everywhere for some extensive example code online, but didn't find anything that I understand how to use.
As Louis mentions, I think that Futures.allAsList etc. could be useful for you. However, I think that Futures.chain does seem useful and appropriate for the situation you describe. Since this is an assignment meant to challenge you, I'm not going to say any more than this: Futures.chain allows you to submit a task for execution upon completion of another task, and it returns a new ListenableFuture representing the result of that task. How does that apply to what you're trying to do?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With