[concurrency-interest] Questions about ThreadPoolExecutor

Kwok, Grace (MSCIBARRA) Grace.Kwok at mscibarra.com
Thu Mar 2 17:50:45 EST 2006


>"This would work too, but doesn't give you a chance to bound the
aggregate thread count.
>You could bound the aggregate thread count using a cached thread pool
and a second semaphore; one that requests nThread permits from the
master semaphore before starting an invokeAll, and returns them when
done.  That way, you could still say "Allow no more than N task
threads", and if too many batches are submitted, they block."


Wouldn't the above subject to our deadlock problem?  (Correct me if I am
wrong.)


So, perhaps I should call the ThreadPoolExecutor constructor,
ExecutorService exec = new ThreadPoolExecutor(10, 100, 10000000,
TimeUnit.NANOSECONDS
								, new
SynchronousQueue(),
	
ThreadPoolExecutor.CallerRunsPolicy());

, put it with your Batch<T> class, and it should serve my needs.

Thank you all very much for your helpful suggestions!

Grace


 

-----Original Message-----
From: Brian Goetz [mailto:brian at quiotix.com] 
Sent: Thursday, March 02, 2006 1:33 PM
To: Joe Bowbeer
Cc: Kwok, Grace (MSCIBARRA); concurrency-interest at cs.oswego.edu
Subject: Re: [concurrency-interest] Questions about ThreadPoolExecutor

> newCachedThreadPool would get you the synchronous queue, but I think 
> you'll need to invoke one of the ThreadPoolExecutor constructors 
> yourself regardless, because none of the Executors factory methods 
> provides everything you need, and you'll need a real 
> ThreadPoolExecutor in order to configure the queue, maximum pool size,

> rejected execution handler, and keep-alive time.

This would work too, but doesn't give you a chance to bound the
aggregate thread count.

You could bound the aggregate thread count using a cached thread pool
and a second semaphore; one that requests nThread permits from the
master semaphore before starting an invokeAll, and returns them when
done.  That way, you could still say "Allow no more than N task
threads", and if too many batches are submitted, they block.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender.  Sender does not waive confidentiality or privilege, and use is prohibited.



More information about the Concurrency-interest mailing list