[concurrency-interest] throwing RuntimeException vs Exception inThreadPoolExecutor
stuff at kai.meder.info
Sun May 30 10:55:43 EDT 2010
On 30.05.2010 01:43, David Holmes wrote:
> It just occurs to me that perhaps you are mistakenly thinking that if a task
> you submit to an executor throws an exception, then that exception will
> somehow appear in the thread that did the submission? That will not happen
> by itself. Exceptions are always local to a given Thread in Java. If you do
> something that results in code executing in another thread, any exceptions
> from that code impact only that other thread - unless you explicitly arrange
> for it to be reported back to the original thread somehow. For example,
> Future.get will throw ExecutionException if the computation (whichever
> thread performed it) threw an exception - but that is because the Future
> implementation has to catch and store the original exception so it can be
> rethrown in the thread doing the get().
> In the executor code you show, any uncaught exception from the task will
> lead to termination of the executor worker thread and invocation of the
> uncaught-exception handler for that thread.
Thanks for describing this en detail. Currently I have the impression
that somehow the Exceptions, occuring inside a submitted task, are
nevertheless propagated to the try-catch clause outside of the task (the
code which submitted the task). But as you stated, this should not be
possible. I will debug this, thanks a lot for your insight.
More information about the Concurrency-interest