[concurrency-interest] PriorityQueue bug with mutable object

Jim Andreou jim.andreou at gmail.com
Thu Jul 2 11:50:23 EDT 2009


How is this different than mutating keys of a HashMap? There is no way a
structure could find out just when an arbitrary memory update causes side
effects to some of its elements.
Java's PriorityQueue does have some shortcomings (it's very slow to change
an element's priority - i.e. through remove and re-add), but this is most
certainly not one of them.

Regards,
Dimitris

2009/7/2 Manuel Dominguez Sarmiento <mads at renxo.com>

> Hi Doug,
>
> I recently filed the following bug at Sun's bug database:
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6856821
>
> You might want to look into it since this class is used by many concurrent
> classes and you're listed as one of its authors.
>
> I am well aware of the perils of mutable objects, however PriorityQueue
> should account for mutability since priorities might change for a queued
> element at runtime, and it is not always practical to remove and discard the
> previous element and create a new object. This does not only affect mutable
> objects but also those whose priority is somehow based on
> System.currentTimeMillis() or other external data, which is what caused us
> to find this subtle bug.
>
> Best,
>
> Ing. Manuel Dominguez Sarmiento
> Director General
> Renxo S.A.
> e-mail: mads at renxo.com
> Phone:  +54 11 4719 6806, ext. 104
>
>
> _______________________________________________
> 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/20090702/773d2ceb/attachment.html>


More information about the Concurrency-interest mailing list