In the callable call() method i write to a database ...
In that case, the exception handling logic needs to be in the call()
method itself; e.g.
public Result call() {
try {
...
if (!Thread.currentThread.isInterrupted()) {
// Save to the database
return result;
} else {
return // some result that means interrupted.
}
catch (Exception ex) {
return // some result that means failed.
}
}
There doesn't seem to be any point in trying to get the main thread to do the database save.