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.
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.