How to propagate exception from thread in java?
exception, java, methods, multithreading, outer-join
Solution
Use FutureTask http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/FutureTask.html#get%28%29 . It's get methods will encapsulate any exceptions from the task that might have run on another thread.
ExecutionException: Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception. This exception can be inspected using the Throwable.getCause() method.
Problem
Code: ``` outerMethod { @Override public void run() { innerMethod throws IOException } } ``` Method that exceuted in thread throws checked exception - IOException. I need to handle this exception in main thread. Like: ``` outerMethod() throws IOException { @Override public void run() { innerMethod() throws IOException } } ``` Is this possible? If no, what would be a better way to do this? Thanks.