A few questions/suggestions - Would it make sense in the contructor to make a clone of the presmably unsynchronized <priorityQueue>. Not doing that would impose the burden of corrent use on the user. - Would it may make sense to sycnhronize the <toString> method. One thread might do an insert operation and another may grab a snapshot via toString before the <insert> method finishes. - Does it make sense to use Doug Lea's util.concurrent package for some of multi threading capabilities or build on that package if there is a need. It may be a good idea reuse really good libraries if they are avaliable. util.concurrent does not seem to have any license hangups and has an excellent reputation. The last time I looked at it, there was some Queue management facilities http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html - Using JDK 1.3 proxies may provide more general purpose wrapping facility. Does the avalon/util/ProxyGenerator provide similar facilities ? I don't think there is a problem in manually writing a few wrappers, but if there are a lot of wrappers written or likely to be written, it may be better to generalize that. It could benefit Avalon code and users of Avalon. Harmeet ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, March 18, 2001 10:16 PM Subject: cvs commit: jakarta-avalon/src/java/org/apache/avalon/util SynchronizedPriorityQueue.java > ramc 01/03/18 22:16:00 > > Added: src/java/org/apache/avalon/util > SynchronizedPriorityQueue.java > Log: > Thread safe version of PriorityQueue. Provides synchronized wrapper methods for all the methods in the PriorityQueue interface. > > Revision Changes Path > 1.1 jakarta-avalon/src/java/org/apache/avalon/util/SynchronizedPriorityQueue.jav a > > Index: SynchronizedPriorityQueue.java > =================================================================== > /* > * Copyright (C) The Apache Software Foundation. All rights reserved. > * > * This software is published under the terms of the Apache Software License > * version 1.1, a copy of which has been included with this distribution in > * the LICENSE file. > */ > package org.apache.avalon.util; > > import java.util.NoSuchElementException; > > /** > * A thread safe version of the PriorityQueue. > * Provides synchronized wrapper methods for all the methods > * defined in the PriorityQueue interface. > * > * @author <a href="mailto:[EMAIL PROTECTED]">Ram Chidambaram</a> > */ > public final class SynchronizedPriorityQueue > implements PriorityQueue > { > protected final PriorityQueue m_priorityQueue; > > public SynchronizedPriorityQueue( final PriorityQueue priorityQueue ) > { > m_priorityQueue = priorityQueue; > } > > /** > * Clear all elements from queue. > */ > public synchronized void clear() > { > m_priorityQueue.clear(); > } > > /** > * Test if queue is empty. > * > * @return true if queue is empty else false. > */ > public synchronized boolean isEmpty() > { > return m_priorityQueue.isEmpty(); > } > > /** > * Insert an element into queue. > * > * @param element the element to be inserted > */ > public synchronized void insert( final Comparable element ) > { > m_priorityQueue.insert( element ); > } > > /** > * Return element on top of heap but don't remove it. > * > * @return the element at top of heap > * @exception NoSuchElementException if isEmpty() == true > */ > public synchronized Comparable peek() throws NoSuchElementException > { > return m_priorityQueue.peek(); > } > > /** > * Return element on top of heap and remove it. > * > * @return the element at top of heap > * @exception NoSuchElementException if isEmpty() == true > */ > public synchronized Comparable pop() throws NoSuchElementException > { > return m_priorityQueue.pop(); > } > > public String toString() > { > return m_priorityQueue.toString(); > } > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]