Methods Summary |
---|
protected boolean | dispatchEvents()Wait until there is something in the event queue to process. Then
dispatch the event to the listeners.The entire method does not
need to be synchronized since this includes taking the event out
from the queue and processing the event. We only need to provide
exclusive access over the code where an event is removed from the
queue.
ControllerEvent evt = null;
synchronized (this){
// Wait till there is an event in the event queue.
try {
while (!killed && eventQueue.size() == 0)
wait();
} catch (InterruptedException e) {
System.err.println("MediaNode event thread " + e);
return true;
}
// Remove the event from the queue and dispatch it to the listeners.
if (eventQueue.size() > 0) {
evt = (ControllerEvent)eventQueue.firstElement();
eventQueue.removeElementAt(0);
}
} // end of synchronized
if (evt != null)
processEvent(evt);
// We have to finish delivering all the events before dying.
return (!killed || eventQueue.size() != 0);
|
public synchronized void | kill()kill the thread.
killed = true;
notifyAll();
|
public synchronized void | postEvent(javax.media.ControllerEvent evt)Queue the given event in the event queue.
eventQueue.addElement(evt);
notifyAll();
|
protected abstract void | processEvent(javax.media.ControllerEvent evt)Invoked when there is at least one event in the queue.
Implement this as a callback to process one event.
|
public void | run()An inifinite while loop to dispatch ControllerEvent.
while (dispatchEvents()) {
// Deliberately empty.
}
|