[concurrency-interest] PooledExecutor vs java.util.concurrent

Jonathan Baxter jbaxter at panscient.com
Tue May 17 17:39:47 EDT 2005


On Friday 18 March 2005 16:49, Tim Peierls wrote:
> Jonathan Baxter wrote:
> > Used to be really easy to create a bounded, blocking thread pool:
> >
> > PooledExecutor pe = new PooledExecutor(10);
> > pe.waitWhenBlocked();
> >
> > Was also easy to increase and decrease the maximum number of threads
> > available, via setMaximumPoolSize and createThreads.
> >
> > How do you get the same behaviour under java.util.concurrent?
>
>   ExecutorService exec = new ThreadPoolExecutor(1, 10, 1, TimeUnit.MINUTES,
>                                           new
> SynchronousQueue<Runnable>());
>
> Doesn't seem too hard. setMaximumPoolSize() is still there, and you can
> prestartAllCoreThreads() instead of createThreads().

But does this block when the pool is full? Doesn't the 
RejectedExecutionHandler get called instead? Seems that ThreadPoolExecutor 
uses BlockingQueue.offer rather than BlockingQueue.put, or am I missing 
something?

Thanks,

Jonathan 

>
> --tim


More information about the Concurrency-interest mailing list