private void postEvent(AWTEvent theEvent, int priority) {
Object source = theEvent.getSource();
if (coalesceEvent(theEvent, priority)) {
return;
}
EventQueueItem newItem = new EventQueueItem(theEvent);
cacheEQItem(newItem);
boolean notifyID = (theEvent.getID() == this.waitForID);
if (queues[priority].head == null)
{
boolean shouldNotify = noEvents();
queues[priority].head = queues[priority].tail = newItem;
if (shouldNotify)
{
if (theEvent.getSource() != AWTAutoShutdown.getInstance())
{
AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
}
notifyAll();
}
else if (notifyID)
{
notifyAll();
}
}
else
{
// The event was not coalesced or has non-Component source.
// Insert it at the end of the appropriate Queue.
queues[priority].tail.next = newItem;
queues[priority].tail = newItem;
if (notifyID) {
notifyAll();
}
}