Choose between ExecutorService's submit and ExecutorService's execute

Viewed 105824

How should I choose between ExecutorService's submit or execute, if the returned value is not my concern?

If I test both, I didn't see any differences among the two except the returned value.

ExecutorService threadExecutor = Executors.newSingleThreadExecutor();
threadExecutor.execute(new Task());

ExecutorService threadExecutor = Executors.newSingleThreadExecutor();
threadExecutor.submit(new Task());
7 Answers

Just adding to the accepted answer-

However, exceptions thrown from tasks make it to the uncaught exception handler only for tasks submitted with execute(); for tasks submitted with submit() to the executor service, any thrown exception is considered to be part of the task’s return status.

Source

Related