[concurrency-interest] Regarding a design suggestion..

Rajesh Balamohan rajesh.balamohan at gmail.com
Wed Mar 14 23:01:55 EDT 2007


Any inputs on this would be of great help Dough.


                ============                 ============
                |          |                 |          |
                |          |                 |          |
Insert Item =>  | Inbound  |                 | Outbound |   ===> out
                |  Queue   |                 |  Queue   |
                |          |                 |          |
                |          |                 |          |
                ============                 ============
                    |                            |
                    |                             |                |
                    |                            |------------- |
    1.    A seperate thread does                                  |
        queue.take() from here                  1.    A seperate thread does
    2. Creates a runnable task and                  queue.take() from
outbound queue
    enques to ThreadPoolExecutor (B)           2. Creates a runnable task
and
                                                enques to ThreadPoolExecutor
(C)




Please let me know if you need more explanation.

1. There are 2 LinkedBlockingQueue. One for inbound and another for outbound
2. There are 3 ThreadPoolExecutors available. Letz say A, B, C
3. Someone puts a task in "A", which puts an item in InboundQueue.
4. A separate thread is blocked on "take()" method of this queue. Once it
gets an item, it
creates another "TASK" and puts it in "B" threadpool.
5. This task does some work and finally enqueues to "OUTBOUND QUEUE"
6. OUTBOUND Queue has a separate thread to dequeue and do some processing in
"C" threadpool.

Problem:
========
1. Too many short lived tasks are created.
2. Too many context switching happening in system due to #1.
3. Do you suggest any better way to implement it. Basic thing is the
queueing and dequeuing has to happen asynchronously.


-- 
~Rajesh.B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070315/b93d16d7/attachment.html 


More information about the Concurrency-interest mailing list