question: 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 ( ) ; } } }
target:  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.