[concurrency-interest] Using concurrent to write a load balancer

Kasper Nielsen kav at it.edu
Mon Sep 18 12:29:31 EDT 2006

Robert Bowen wrote:
> My only other question is how to cancel the other tasks that finish after the first one, so they are available again for the next request? I know I can cancel tasks using Future.cancel() but if I use a FutureTask instead of a Callable, then I can't use invokeAny() ...
invokeAny automatically interrupts all threads that have not finished 
before returning the result. However, for some reason isReachable() does 
not respond to interrupt signals. So not much you can do about that.

If it turns out to be a problem you would probably need to add some more 
threads to the pool (don't worry to much about the overhead) or use 
java.lang.Runtime to execute an external ping application

You might also want to checkout this previous thread

- Kasper

More information about the Concurrency-interest mailing list