[concurrency-interest] PriorityLinkedQueue ?

rbalamohan rbalamohan at sonoasystems.com
Tue Sep 12 03:44:46 EDT 2006


My bad in not giving the complete details. Sorry about that..

Actually we can make use of PriorityBlockingQueue. However, this is
unbounded. 

There can be requirements where we need BOUNDED PriorityBlockingQueue.

ex: Throttling number of workers in a application server or servlet
container or something like that.

1. Lots of requests come in and we need to prioritize them and hand it
over to the ThreadPoolExecutor.
2. Problem of using PriorityBlockingQueue in this case is that, it is
unbounded. However, we need to restrict the number of requests coming
in, so that the "Discard Policy" of the ThreadPoolExecutor can kick in.

~Rajesh.B

On Mon, 2006-09-11 at 21:46 -0700, Hanson Char wrote:

> Oops, forget about the "delay" priority.  Better to directly use
> j.u.c.PriorityBlockingQueue and implement Comparable for each q item.
> There is still no "decrease Key" operation  in PriorityBlockingQueue
> though ... 
> 
> H
> 
> On 9/11/06, Hanson Char <hanson.char at gmail.com> wrote:
> 
>         >This might be useful for creating work load with priority
>         associated with it and submitting 
>         > to the threadpool executor.
>         
>         If you can determine the priority of each work item a priori,
>         you can assign it an expired "delay" and place it on a
>         j.u.c.DelayQueue.  The higher the prioirty, the further into
>         the past a work item should be "expired".
>         
>         The consumer(s) can then dequeue/process items with a priority
>         according to their expiration.
>         
>         However, if the prioirty of each work item needs to be changed
>         after it has been placed on the queue, then this won't work as
>         DelayQueue would ignore such changes.
>         
>         It would be really nice if there is a "decrease Key" operation
>         as Tim Peierls pointed out earlier under the email thread
>         "Changing delays in DelayQueue ?"
>         
>         Hanson
>         
>         On 9/11/06, Hanson Char <hanson.char at gmail.com> wrote:
>         
>                 Is j.u.PriorityQueue what you are looking for ?
>                 
>                 
>                 Hanson
>                 
>                 
>                 On 9/11/06, rbalamohan <rbalamohan at sonoasystems.com>
>                 wrote:
>                 
>                         The results look really promising. 
>                         
>                         On a similar note, I was wondering why we
>                         don't have "PRIORITY BASED LINKED QUEUE"
>                         
>                         This might be useful for creating work load
>                         with priority associated with it and
>                         submitting to the threadpool executor.
>                         
>                         ~Rajesh.B
>         
>         
>         
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060912/49f4508a/attachment.html 


More information about the Concurrency-interest mailing list