Re: Seeming Non-determinism in Java Programs

Stephen Denne <[email protected]> Mon, 7 Apr 2008 15:56:26 +1200
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
Randall R Schulz wrote:
> On Sunday 06 April 2008 20:07, Stephen Denne wrote:
> > Randall R Schulz wrote:
> > > The queue is
> > > implemented using a heap, though alternatives such as Skip-Lists
> > > are available as options (mostly implemented because of the issue
> > > I'm writing about here).
> >
> > You haven't explicitly mentioned it... but are you using
> > java.util.PriorityQueue?
> 
> No. But I think it's of the same lineage. I originally took 
> it from Doug
> Lea's Heap code and removed the synchronization (it was quite a while
> ago, and I figured the synchronization overhead was not worth it for a
> single-threaded application). Probably nowadays the synchronization
> would not impose a significant / measurable overhead, but at the time
> (java 1.3) that was not so.

For reference, java.util.PriorityQueue javadocs say:

Note that this implementation is not synchronized. Multiple threads should not access a PriorityQueue instance concurrently if any of the threads modifies the queue. Instead, use the thread-safe PriorityBlockingQueue class. 

http://java.sun.com/javase/6/docs/api/java/util/PriorityQueue.html

Regards,
Stephen Denne.

Disclaimer:
At the Datamail Group we value team commitment, respect, achievement, customer focus, and courage. This email with any attachments is confidential and may be subject to legal privilege.  If it is not intended for you please advise by reply immediately, destroy it and do not copy, disclose or use it in any way.
__________________________________________________________________
  This email has been scanned by the DMZGlobal Business Quality
              Electronic Messaging Suite.
Please see http://www.dmzglobal.com/dmzmessaging.htm for details.
__________________________________________________________________

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com