I have a program which uses executorService
to which I am passing callables
.
Each of which is an object of one class which implements java.util.concurrent.Callable
.
Then the executorService
is invoked. A java.lang.NoClassDefFoundError
is thrown in the middle of one of the callables in the call()
method.
However it is not terminating nor getting logged on the console. Therefore there is no way to know if the program has worked correctly or not. Kindly suggest any way by which I can understand the same.
Some one had already posted answer to this question, but when I came to mark it as answer after verifying, the post was unfortunately deleted. I am just retyping the answer.
The Futures which are returned by the ExecutorService after calling the invoke method contain all the Future objects of the thread. If anything goes wrong in any of the threads, an
java.util.concurrent.ExecutionException
is thrown. Which can be detected in the parent thread which owns the executorService when we doget()
on the Future. Thene.getCause()
after catching it will get us the actual object which caused an error/exception.