top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is difference between Executor.submit() and Executer.execute() method ?

0 votes
552 views
What is difference between Executor.submit() and Executer.execute() method ?
posted Jan 12, 2017 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There is a difference when looking at exception handling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you don't have provided one explicitly, the default one will just print the stack trace to System.err). If you submitted the task with submit any thrown exception, checked exception or not, is then part of the task's return status. For a task that was submitted with submit and that terminates with an exception, the Future.get will re-throw this exception, wrapped in an ExecutionException.

answer Jan 23, 2017 by Dhaval Vaghela
...