--- projects/cms/source/util/uk/org/iscream/cms/util/Queue.java 2001/03/16 15:17:06 1.17 +++ projects/cms/source/util/uk/org/iscream/cms/util/Queue.java 2001/03/22 18:23:27 1.19 @@ -14,7 +14,7 @@ import uk.org.iscream.util.*; * actually contains some elements. * * @author $Author: tdb $ - * @version $Id: Queue.java,v 1.17 2001/03/16 15:17:06 tdb Exp $ + * @version $Id: Queue.java,v 1.19 2001/03/22 18:23:27 tdb Exp $ */ public class Queue { @@ -23,7 +23,7 @@ public class Queue { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.17 $"; + public static final String REVISION = "$Revision: 1.19 $"; /** * Pass to constructor to remove a RANDOM item from @@ -136,8 +136,8 @@ public class Queue { throw new InvalidQueueException("Requested queue "+queue+" does not exist"); } // block if the queue is empty - if (((LinkedList) _lists.get(queue)).size() == 0) { - synchronized(((LinkedList) _lists.get(queue))) { + synchronized(((LinkedList) _lists.get(queue))) { + if (((LinkedList) _lists.get(queue)).size() == 0) { try { ((LinkedList) _lists.get(queue)).wait(); } catch(Exception e) {} } } @@ -247,7 +247,7 @@ public class Queue { * * @return An integer to be passed to the get() method. */ - public int getQueue() { + public synchronized int getQueue() { int pos = -1; for(int i=0; i < _lists.size(); i++) { if(_lists.get(i) == null) { @@ -271,7 +271,7 @@ public class Queue { * * @param queue The integer identifier for the queue, given by getQueue(). */ - public void removeQueue(int queue) { + public synchronized void removeQueue(int queue) { _lists.set(queue, null); }