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

Tim Peierls tim at peierls.net
Fri Mar 18 01:19:00 EST 2005

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().


More information about the Concurrency-interest mailing list