[concurrency-interest] Class striped/ordered Thread Pool

Joe Bowbeer joe.bowbeer at gmail.com
Sat May 12 21:54:17 EDT 2012


On Fri, May 11, 2012 at 12:22 PM, Andrew Trumper wrote:

>
> BoundedExecutor is a simple wrapper that limits the number of concurrently
> running tasks to some number. It doesn't allocate any threads itself
> (unless you want it to) but uses the "mThreadCache". It's great because it
> means your whole application can use one thread cache but you can create
> little thread pools all over the place and not worry about having a bunch
> of idle threads hangin' around. We use this all the time in our product.
>
> (Note, that Joe Bowbeer has mentioned a class called SerialExecutor that
> seems to do the same thing. ?)
>
> BoundedExecutor is part of the nuggu library, BSD license:
>
> <http://nuggu.svn.sourceforge.**net/viewvc/nuggu/HEAD/src/com/**
> intelerad/tools/lib/**concurrent/BoundedExecutor.**
> java?revision=10&view=markup<http://nuggu.svn.sourceforge.net/viewvc/nuggu/HEAD/src/com/intelerad/tools/lib/concurrent/BoundedExecutor.java?revision=10&view=markup>
> >
>
> It would be really great to improve this class and put it in a library
> someone's actually heard of :-P.
>
> (In our product we sometimes use a second BoundedExecutor around the
> thread cache to limit the concurrency to the number of cores/processors.)
>


The SerialExecutor that I referred to is in the Executor javadoc.

http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.html

Here is a link to one of the times that a similar problem was discussed
previously on c-i:

http://cs.oswego.edu/pipermail/concurrency-interest/2010-June/007208.html

This post refers to both SerialExecutor and a (different) BoundedExecutor.

There are several different SerialExecutor and BoundedExecutor
implementations floating around.  In one way, this validates the usefulness
of the simple Executor interface!  In real world applications, I wonder if
a single BoundedExecutor implementation would be useful.  Shutdown is one
of the missing pieces in these sample implementations -- and this is
especially difficult to manage when there are multiple, delegating
executors.  I expect that different trade-offs would be chosen in different
situations, in which case it may be hard to provide a general solution.

--Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120512/2c11ab50/attachment.html>


More information about the Concurrency-interest mailing list