[concurrency-interest] ExecutorCompletionService

Peter Kovacs peter.kovacs.1.0rc at gmail.com
Sun Jan 7 17:16:05 EST 2007


Hi,

I am looking at using the class ExecutorCompletionService (
http://dcl.mathcs.emory.edu/util/backport-util-concurrent/doc/api/edu/emory/mathcs/backport/java/util/concurrent/ExecutorCompletionService.html
). 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.

My motivation in looking for this kind of behavior is that I have a
large number of calculations to be concurrently done. The number of
calculations is defined by an external input source which potentially
far exceeds the system memory available. So waiting calculation tasks
cannot indefinitely be "buffered" in the system -- wherever they're
waiting: either in client queue(s) or in the threadpool (waiting for
CPU).

1.) Is there such a ThreadPool executor implementation already
existing out there?

2.) I assume that --when used whith such a ThreadPool-- the
ExecutorCompletionService.submit method
(http://dcl.mathcs.emory.edu/util/backport-util-concurrent/doc/api/edu/emory/mathcs/backport/java/util/concurrent/ExecutorCompletionService.html#submit(edu.emory.mathcs.backport.java.util.concurrent.Callable)
will block when there are no more threads available in the pool. Is
this correct?

3.) Is having calls to ExecutorCompletionService.submit wait for free
worker threads a good practice at all? (It is definitely easy to use
on the client side, but who knows...there may be considerations
against it)

Thanks
Peter


More information about the Concurrency-interest mailing list