How to design an execution engine for a sequence of tasks

前端 未结 10 1977
南方客
南方客 2021-02-01 17:16

I am trying to code a problem in Java where I have to execute a bunch of tasks.

Problem

Execute a job which consists of multiple tasks and thos

10条回答
  •  北海茫月
    2021-02-01 17:52

    If you want to reinvent the wheel and develop the solution yourself, fine - it's your choice. However doing this properly is rather hard, especially the threading part. However, if you can consider some outside help with at least the building blocks, those can be:

    • guava's ListenableFuture - using this library you can create Callables and feed them to special thread pool executor, which then allows custom callbacks on ListenableFuture completion.
    • you could take a look at RX Java Observable which allows mixing and matching different tasks. This uses non-imperative coding style so beware!

提交回复
热议问题