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

Jonathan Baxter jbaxter at panscient.com
Fri Mar 18 06:52:40 EST 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().

Ah - hadn't spotted SynchronousQueue. Thanks for the pointer. There are a lot 
more moving parts to bolt together to get the same behaviour in 
java.util.concurrent. 

- jonathan 

>
> --tim


More information about the Concurrency-interest mailing list