void dispatchEvents(){
  EventInfo eventInfo=null;
synchronized (this) {
    try {
      if (eventQueue.size() == 0) {
        if (autoClosingClips.size() > 0 || lineMonitors.size() > 0) {
          int waitTime=AUTO_CLOSE_TIME;
          if (lineMonitors.size() > 0) {
            waitTime=LINE_MONITOR_TIME;
          }
          wait(waitTime);
        }
 else {
          wait();
        }
      }
    }
 catch (    InterruptedException e) {
    }
    if (eventQueue.size() > 0) {
      eventInfo=(EventInfo)eventQueue.remove(0);
    }
  }
  if (eventInfo != null) {
    processEvent(eventInfo);
  }
 else {
    if (autoClosingClips.size() > 0) {
      closeAutoClosingClips();
    }
    if (lineMonitors.size() > 0) {
      monitorLines();
    }
  }
}

void dispatchEvents ( ) { EventInfo eventInfo = null ; synchronized ( this ) { try { if ( eventQueue . size ( ) == 0 ) { if ( autoClosingClips . size ( ) > 0 || lineMonitors . size ( ) > 0 ) { int waitTime = AUTO_CLOSE_TIME ; if ( lineMonitors . size ( ) > 0 ) { waitTime = LINE_MONITOR_TIME ; } wait ( waitTime ) ; } else { wait ( ) ; } } } catch ( InterruptedException e ) { } if ( eventQueue . size ( ) > 0 ) { eventInfo = ( EventInfo ) eventQueue . remove ( 0 ) ; } } if ( eventInfo != null ) { processEvent ( eventInfo ) ; } else { if ( autoClosingClips . size ( ) > 0 ) { closeAutoClosingClips ( ) ; } if ( lineMonitors . size ( ) > 0 ) { monitorLines ( ) ; } } }
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 .
