Java multithreading errors handling

error-handling, java, multithreading

Solution

If you use the java.util.concurrent Executor frameworks and generate a Future from each submitted worker, then calling get() on the Future will either give you the worker's result, or the exception thrown/caught within that worker.

Problem

I have one main thread it has created many workers, every worker is a thread. How can I get errors from the workers in main thread if there was an Exception in some worker or worker cannot successfully ended ? How to send error before the worker thread dead ?

Original source

Related problems