[concurrency-interest] ExecutorCompletionService is dangerous for critical app!?

Doug Lea dl at cs.oswego.edu
Fri Aug 11 14:16:37 EDT 2006

yangjs wrote:
>    I  use ExecutorCompletionService in my app ,that is a 
> producer-consumer pattern. code like follow:
>     ExecutorCompletionService jobQueue = new
>     ExecutorCompletionService<Document>(
>        getThreadExecutor(), getBlockingQueue(100));/
>        when queue  full, completionQueue.add(this) will throw exception
>     but swallowed by Future self.

Sorry that the javadoc did not make clear that the supplied queue
should be unbounded. This should/will be clarified. The rationale
for not using BlockingQueue.put here is that there is no
policy control in this simple class for dealing with either
InterruptedExceptions that might occur with put, or the potential
for saturation and lockup.

Unless/until we get good suggestions for dealing with
such things in a generic way, I'm afraid that in those cases
where you have to deal with them, you'll need a custom
implementation of the CompletionService interface.


More information about the Concurrency-interest mailing list