public void run() { try { customResultAvailable(result); } catch(Exception e) { // Could happen that overridden customResultAvailable method // first sets result and then throws exception (listener ex are catched). future.setExceptionIfUndone(e); // if(undone) // { // future.setExceptionIfUndone(e); // } // else // { // future.setException(e); // } } } });