Grabs the entire queue in an enumeration and calls observeChange()
in each one.
while( true ) {
Enumeration elems;
// Grab a queue enumeration quickly and release
// the synchronization.
synchronized(queue) {
if( !queue.isEmpty() ) {
elems = queue.elements();
queue = new Vector();
}
else {
elems = null;
}
}
if( elems != null ) {
while( elems.hasMoreElements() ) {
ChangeObserver o = (ChangeObserver)elems.nextElement();
o.observeChange();
}
}
try { Thread.sleep(500); }
catch( InterruptedException e ) { }
}