Methods Summary |
---|
public synchronized java.lang.Object | get()Get the first object out of the queue. Return null if the queue
is empty.
Object object = peek();
if (object != null)
vector.removeElementAt(0);
return object;
|
public boolean | isEmpty()Is the queue empty?
return vector.isEmpty();
|
public java.lang.Object | peek()Peek to see if something is available.
if (isEmpty())
return null;
return vector.elementAt(0);
|
public synchronized java.lang.Object | pull()Pull the first object out of the queue. Wait if the queue is
empty.
while (isEmpty()) {
try {
waiting=true;
wait();
} catch (InterruptedException ex) {
}
waiting=false;
if( stopWaiting ) return null;
}
return get();
|
public synchronized void | put(java.lang.Object object)Put the object into the queue.
vector.addElement(object);
notify();
|
public int | size()How many elements are there in this queue?
return vector.size();
|
public synchronized void | stop()Break the pull(), allowing the calling thread to exit
stopWaiting=true;
// just a hack to stop waiting
if( waiting ) notify();
|