[concurrency-interest] ExecutorCompletionService

Holger Hoffstätte holger at wizards.de
Mon Jan 8 03:32:15 EST 2007


Peter Kovacs wrote:
> I would like to use some kind of ThreadPool executor for execution
> which blocks when the maximum number of threads in the pool is reached
> and all threads are utilized.

As Joe pointed out this existed in the Doug Lea's original concurrent
library, and since I needed it for backwards compatbility I "ported" it
(accidentally for use with the backport lib too):

source:
http://fisheye.codehaus.org/browse/mule/trunk/mule/core/src/main/java/org/mule/util/concurrent/WaitPolicy.java?r=trunk

test case:
http://fisheye.codehaus.org/browse/mule/trunk/mule/tests/core/src/test/java/org/mule/test/util/concurrent/WaitPolicyTestCase.java?r=trunk

Feel free to use it any way you want; if you have questions drop me a line.

That being said, waiting for the pool/queue only works for certain amounts
of work and producer/consumer ratios: if you produce work more quickly
than you consume it over an extended period of time, you will eventually
run out of something, somewhere, unless you throttle.

cheers
Holger


More information about the Concurrency-interest mailing list