[concurrency-interest] Re: Help, how to design a pool of threads

Doug Lea dl at cs.oswego.edu
Sat Nov 5 10:20:58 EST 2005


Andrej Navodnik wrote:
> 
> My questions are:
> - how should I design my application so that the tasks
> 
> in the pool would be canceled/stopped after the 
> optimal element is found except for the task 
> that has found that “optimal element” - I wouldn't 
> like to see the message “Task is still doing useless
> things” because it's actually using resources that
> should be used fior preparing the final result;
> - should I concern about this problem or not?
> - are there any other constructs that I could 
> use and achieve the same result?
> 

You might find the second code example in the ExecutorCompletionService
javadoc helpful. See

http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ExecutorCompletionService.html

-Doug




More information about the Concurrency-interest mailing list