[concurrency-interest] ThreadPoolExecutor with corePoolSize as Zero

Moran Avigdor moran at gigaspaces.com
Tue Dec 18 10:16:28 EST 2007


When initializing a thread pool with a core-pool-size of Zero I see that
no threads execute the runnable tasks.

Looking at this further it seems that only if the queue rejected the
offer, then a first thread will be created.

 

A ThreadPoolExecutor with a SynchronousQueue() will work - but a
LinkedBlockingQueue() will not.
Is this considered a known limitation? Must I initialize my pool with
corePoolSize as 1 with an unbounded queue?

 

ThreadPoolExecutor pool = new ThreadPoolExecutor(0, 10, 60L,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());

            

for (int i=0; i<10; ++i)

{

      pool.execute(new Runnable() {

            public void run() {

                  System.out.println("running");

            };

});

}

 

Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20071218/6f86b468/attachment.html 


More information about the Concurrency-interest mailing list