In this blog post we will discuss about one of the very important java interview question What is difference between Executor submit() and execute() method?
- There is a difference the way both methods handle Exception. If your tasks throws an exception and if it was submitted with execute(Runnable) this exception will go to the uncaught exception handler.
- If you submitted the task with submit(Callable) any thrown exception, checked exception or not, is then part of the task’s return status.
- For a task that was submitted with submit(Callable) and that terminates with an exception, theget() will re-throw this exception, wrapped in an ExecutionException.
What are common multi-threading issues faced by Java Developers?
What are different states of a Thread? What does those states tell us?
What happens when wait() & notify() methods are called?
What is difference between sleep(), yield() and wait() method?
What is difference between Callable and Runnable Interface?
What will happen when an exception arises from within a synchronized code block? Will lock be retained or released?
That’s all about What is the difference between Executor submit() and execute() method?
If you have any feedback or suggestion please feel free to drop in below comment box.