File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes execute vs submit ( threadPoolExecutor) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply locked New topic

execute vs submit ( threadPoolExecutor)

Steven Rodeo
Ranch Hand

Joined: Mar 06, 2008
Posts: 72

Sorry if this sound too basic... What is the difference between a submit and an execute of a Runnable task in a ThreadPoolExecutor.

A sample code fails with a RejectedExecutionException when we attempt to use execute ( Ofcourse Calling the shutdown on the ThreadPoolExecutor )

The same code 'Seems' to work with submit... Are we lucky ? or is it some race condition or a difference between execute and submit that eludes me ?

Thanks a bunch...
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

Please do not Cross-post the same question in multiple forums.
Let us continue the discussion here

apigee, a better way to API!
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33111

Thanks for pointing that out Nitesh!

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: execute vs submit ( threadPoolExecutor)
It's not a secret anymore!