intermediateConcurrency Utilities

What is the difference between submit() and execute() on an ExecutorService?

execute(Runnable) simply runs the task and returns void, giving you no way to track when it finishes or to retrieve any exception it threw. submit(Runnable) instead returns a Future<?> that you can call get() on to block until the task completes and to discover whether it threw an exception; submitting a Callable<T> similarly returns a Future<T> that lets you retrieve the task's actual result. The key practical difference is exception handling: an unchecked exception thrown from a Runnable passed to execute() is silently reported to the thread's UncaughtExceptionHandler and never reaches the caller, whereas any exception thrown by a task submitted via submit() is captured inside its Future and re-thrown, wrapped, when you call get(). Because of this, submit() should generally be preferred in production code so failures aren't silently swallowed.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to How do you correctly and safely shut down an ExecutorService?← Back to all Java Concurrency & Multithreading questions