[concurrency-interest] blocking executor
jed at atlassian.com
Mon Sep 11 04:35:28 EDT 2006
I have been charged with implementing an ExecutorService that has a
bounded capacity, and if that capacity is reached will block the caller.
A CallerRunsPolicy is not desired here as the number of concurrent tasks
executing must be strictly held to the number of threads in the pool,
and the number of clients adding tasks is indeterminate.
Having looked at the code for a while, it seems a
BlockingRejectedExectionHandler should do the trick eg.
RejectedExecutionHandler blocker = new RejectedExecutionHandler()
public void rejectedExecution(Runnable r, ThreadPoolExecutor
throw new RejectedExecutionException(executor + " is
catch (InterruptedException e)
throw new RejectedExecutionException(e);
The question is, are there any better ways to do this, or are there any
obvious errors in the above.
All advice greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest