The check of the condition (`systemEventQueue.isEmpty()`) should be performed while holding the synchronization monitor of the `systemEventQueue` object. Otherwise, it's possible that another thread will insert an element into the queue after this thread checks the condition but before this thread enters the wait, in which case this thread will wait unnecessarily and might never be awakened.