-1

I think both of them will execute the thread task in some time in the future, why two methods?

user496949
  • 83,087
  • 147
  • 309
  • 426

2 Answers2

4

Execute() doesn't return a value, whereas submit() returns a Future that can be use to get the return value from the executed code.

execute() is there because it's part of the Executor interface which ExecutorService extends, most likely only so there can be a very simple interface.

Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77
0

submit returns a Future, which allows you to get information about the task after it is complete.

Tony R
  • 11,224
  • 23
  • 76
  • 101