aspose file tools
The moose likes Threads and Synchronization and the fly likes ThreadPoolExecutor constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "ThreadPoolExecutor constructor" Watch "ThreadPoolExecutor constructor" New topic
Author

ThreadPoolExecutor constructor

Andrew Rigsby
Greenhorn

Joined: Oct 05, 2006
Posts: 15
The thread pool executor takes a blocking queue as its argument (i.e. the work queue) which according to the API’s is used for “… holding tasks before they are executed”

If a thread pool executor is permitted a maximum of 2 threads and has a fixed size work queue of 1 ….. if the main thread calls submit() twice before one of the pooled threads has a chance to execute will this result in the second call to submit() throwing an exception because of the size of the work queue being exceeded.

I’m just slightly confused by the following description from the API:

• If fewer than corePoolSize threads are running, the Executor always prefers adding a new thread rather than queuing.
• If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread.
• If a request cannot be queued, a new thread is created unless this would exceed maximumPoolSize, in which case, the task will be rejected.

As “fewer than corePoolSize threads are running”, i.e. no threads are running, does the work queue actually get used (and so is its size relevant)?
 
I agree. Here's the link: jrebel
 
subject: ThreadPoolExecutor constructor
 
Similar Threads
executing time-bounded job
Limit concurrent threads; report successful execution; terminating hung threads
Parent Thread should wait till all child thread are dead
Doug Lea PooledExecutor won't grow larger than minimumPoolSize
ExecutorService invokeAll - blocking?