[concurrency-interest] Class striped/ordered Thread Pool

Joe Bowbeer joe.bowbeer at gmail.com
Fri May 11 09:21:24 EDT 2012


I think some similar problems have been discussed here and the solution I
recall is to use a SerialExecutor per stream, where each executor would
share the same ThreadPoolExecutor. The serial executor is in the javadocs.
It just wraps tasks to ensure that at most one is executing on the thread
pool at one time.
On May 11, 2012 12:17 AM, "Glenn McGregor" <glenn at 8950aaa.com> wrote:

>  On 5/10/2012 10:07 PM, David Holmes wrote:
>
> Not sure if this makes sense unless you use a SingleThreadExecutor per
> stripeClass. Otherwise you have races in the submission of StripedRunners
> of the same stripeClass, and even if you order the queue so that they start
> execution in the right order, you can't guarantee what order they will
> complete in. Unless it is all done by a single thread.
>
> David Holmes
>
>
> I can guarantee that items of the same class are generated by one thread.
>
> To expand on my particular use case...
>
> I have a small number of threads using NIO to read multiple TCP or SCTP
> data streams.
> I need to process TLS in order for a given socket.
> But a given TLS stream is only read by one thread.
>
> So what I want to hand off my TLS work to a thread pool, but need to keep
> particular streams in sequence.
>
> Thanks
>
>
> Glenn McGregor
>
>
>  -----Original Message-----
> *From:* concurrency-interest-bounces at cs.oswego.edu [
> mailto:concurrency-interest-bounces at cs.oswego.edu<concurrency-interest-bounces at cs.oswego.edu>
> ]*On Behalf Of *Glenn McGregor
> *Sent:* Friday, 11 May 2012 2:54 PM
> *To:* concurrency-interest at cs.oswego.edu
> *Subject:* [concurrency-interest] Class striped/ordered Thread Pool
>
>  Hello all,
>
> I'm looking for a thread pool with the following characteristics... (in
> pseudo-code)
>
> interface StripedRunner {
>     Object getStripeClass();
>     void run();
> }
>
> magicPool.execute( stripedRunner );
>
> The idea being that any StripedRunners with the same stripeClass would get
> executed in the order they were queued,
> but StripedRunners with different stripedClasses could execute
> independently.
>
> Is there a way to configure the standard concurrent pools to work this way
> (doesn't seem to be), or a way to extends
> the current code?
>
> Or perhaps some third party library implementation?
>
> Thanks!
>
> Glenn McGregor
>
>
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120511/72cc9b5e/attachment-0001.html>


More information about the Concurrency-interest mailing list