Suppose I have a few tasks to run in parallel in Java. Each task returns either success or failure. Each task has an associated deadline. If a task does not finish by the deadline it is interrupted (all tasks are interruptable) and returns failure.
If one of the tasks fails (i.e. return failure) we interrupt all other tasks, which are still running.
We should wait till all tasks finish and finally return either success if all tasks return success or failure if at least one task returns failure.
How would you implement it? I am going to use util.concurrent. Which library primitives would you suggest?