I’m running multiple idempotent tasks to gather one batch of data. I found out that many times the computation is delayed significantly due to a couple of tasks out of a hundred.
What I’d like is a way of watching these tasks and launching the stragglers again if they are significantly delayed.
Is there a standard library or idiom for doing this in Java? I’m currently using the ExecutorService/ExecutorCompletionService pair to get the job done.
If you have access to the Future object representing this task, then you could check
isDone()andcancel()if required. You’d have to poll these future objects and resubmit accordingly. It also depends on your underlying Runnables handling InterruptExceptions appropriately.