[concurrency-interest] Is there a ConcurrentBlockingQueue ??

Rajesh Balamohan rajesh.balamohan at gmail.com
Mon Mar 19 23:39:04 EDT 2007


Thankx a lot Hanson and David for the quick replies. I am trying out
ConcurrentLinkedBlockingQueue as given in Hanson's site. Will post the
results soon after doing the perf benchmark with our project.

~Rajesh.B

On 3/20/07, Hanson Char <hanson.char at gmail.com> wrote:
>
> Have you checked this out ?
>
>
> http://hansonchar.blogspot.com/2006/09/concurrentlinkedblockingqueue.html
>
> Cheers,
> Hanson
>
> On 3/19/07, Rajesh Balamohan <rajesh.balamohan at gmail.com> wrote:
> > Hi All,
> >
> > We are using LinkedBlockingQueue since it blocks on take() method. We
> have a
> > requirement like the following.
> >
> > 1. Many tasks are submitted to a threadpool by different threads. The
> task
> > internally adds some item to a LinkedBlockingQueue. I have striped down
> most
> > of the logic below. Please ignore the contents as such.
> >
> > //The following task will be submitted by a pool of threads to a
> > threadPoolExecutor.
> >  static class Request implements Runnable {
> >
> >         MessageState state = new MessageState();
> >
> >         public void run() {
> >             synchronized (state) {
> >                 if (!state.isRequestStarted()) {
> >
> > state.addEvent(MessageState.EVENT.REQUEST_RECEIVE_COMPLETE);
> >                 }
> >             }
> >              myLinkedBlockingQueue.add(state);
> >         }
> >     }
> >
> > 2. One reaper thread is created whose job is to keep on taking out the
> items
> > from the LinkedBlockingQueue (basically like the following)
> >
> > while(true) {
> >   accept();
> > }
> >
> > private void accept() {
> >   try {
> >      MyItem item = myLinkedBlockingQueue.take();
> >  } ...blah blah...
> > ..........
> > ......
> > do necessary processing.
> > }
> >
> >
> >  Now, I feel that it should be ConcurrentLinkedQueue instead of
> > LinkedBlockingQueue. ConcurrentLinkedQueue might be able to scale well
> than
> > LinkedBlockingQueue for multiple threads.
> >
> > Problem is ConcurrentLinkedQueue doesn't have a blocking take(). Are
> there
> > any plans to add it? Or you think that this problem can be solved
> > differently?
> >
> > --
> > ~Rajesh.B
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> >
>



-- 
~Rajesh.B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070320/696a31bd/attachment.html 


More information about the Concurrency-interest mailing list