I have checked Oracle Java API, which gives some info that FutureTask.isDone()
but I need to check whether the task has completed or terminated with any error. isDone() method will return even if it completes/terminates. But I need to know whether it's completed or terminated due to some problem.
If the FutureTask
is done, call get()
afterwards (can be without any timeout, it should return immediately). It will either return some result or throw:
ExecutionException
- if the computation threw an exception
ExecutionException.getCause()
will return the exception thrown from your task.
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