[concurrency-interest] Task Queue ordering

Joe Bowbeer joe.bowbeer at gmail.com
Wed Dec 2 22:16:30 EST 2009

If each client's tasks are executed sequentially, you can use a
SerialExecutor per client.  See the "SerialExecutor" example in the Executor
javadoc.  Each client's executor would delegate to the shared thread pool

If all tasks can execute in concurrently, but you want to retire them in
order, I think there was a useful discussion about this in June '08.
Search for "Out-of-order execution, in-order retirement".

(The suggestion was to queue the Futures when the Callables are submitted,
and retire the tasks in the order they were enqueued.)


On Wed, Dec 2, 2009 at 6:32 PM, Ken-- at newsgroupstats.hk wrote:

> Hi All,
> I have a Task Queue (ArrayBlockingQueue) with single thread for client's
> task processing. For same client, I  have to guarantee the ordering of task
> results as I need the result of previous task to perform next task of the
> same client. It's work for ArrayBlockQueue with single thread as it's
> always
> My question is, how to enable multi threads (like ThreadPoolExecutor) for
> queue but maintaining the ordering of same client's tasks? I tried
> PriorityBlockingQueue but it just ensure tasks are started in order.
> Any solution? Please help.
> Thanks and Best Regards,
> Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20091202/c1d51341/attachment.html>

More information about the Concurrency-interest mailing list