Example & Tutorial understanding programming in easy ways.

Difference between submit() and execute() method thread pool in Java?

Both method are ways to submit task to thread pools but there is slight difference
between them.

execute(Runnable command) is defined in Executor interface and
executes given task in future, but more importantly it does not return anything. It's
return type is void.

On other hand submit() is overloaded method, it can take
either Runnable or Callable task and can return Future object which can hold
pending result of computation.

This method is defined
on ExecutorService interface, which extends Executor interface, and every
other thread pool class
e.g. ThreadPoolExecutor or ScheduledThreadPoolExecutor gets these
methods.

Read More →
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!