I am writing an Spring-mvc application.
I am executing task using ThreadPoolTaskExecutor.
I have below sample code.
MyClass.java
public class MyClass {
    public void startProcess() {
        ThreadPoolTaskExecutor taskExecutor = //Initializing 
        for (int i = 1; i <= 5; i++) {
            taskExecutor.execute(new MyRunnable());
            // I can call taskExecutor.submit(task); also, if required
        }
    }
}
MyRunnable.java
public class MyRunnable implements Runnable {
    @Override
    public void onRun() {
        try {
            //Code which generates exception like below
            throw new Exception("Runtime Exception");
        } catch (Exception e1) {
            // log or throw the exception
        }
    }
}
I want to notify startProcess() about the exception occurred in MyRunnable's run method.
Can any one please guide me for this.
I found below links but it is not solving my problem.
- Handling exceptions from Java ExecutorService tasks
- http://java.dzone.com/articles/spring-async-and-exception
Thanks.
Edit:
One more question. If I am using @Async for asynchronous call to my some other method and If I want to check for the exception occured in async method then what should I do? As async method also returns future object.
Answer for @Async question I got from here
 
     
     
    