ExecutorService has two methods:
void execute(Runnable command) and
Future<?> submit(Runnable task) .
What is the difference between them in the behavior of threads, except for the return value?
ExecutorService has two methods:
void execute(Runnable command) and
Future<?> submit(Runnable task) .
What is the difference between them in the behavior of threads, except for the return value?
In the ForkJoinPool , ThreadPoolExecutor, and AbstractExecutorService classes, the submit uses execute . In the class ScheduledThreadPoolExecutor, submit and execute use the overloaded method schedule . So there is no difference.
execute is a method from the Executor interface
submit is a method from the ExecutorService interface that extends Executor .
Since submit returns a value, it prepares the return value.
Source: https://ru.stackoverflow.com/questions/910196/
All Articles