What is the difference between `ExecutorService.submit()` and `ExecutorService.execute()` in Java?

Java Associate Hard

Java Associate — Hard

What is the difference between `ExecutorService.submit()` and `ExecutorService.execute()` in Java?

Key points

  • `execute()` returns void, while `submit()` returns a Future
  • `submit()` can handle Callable in addition to Runnable
  • `submit()` enables exception retrieval and result collection
  • `execute()` is more basic and synchronous compared to `submit()`

Ready to go further?

Related questions