1076 1077 final void detachDispatchThread(EventDispatchThread edt) { 1078 /* 1079 * Minimize discard possibility for non-posted events 1080 */ 1081 SunToolkit.flushPendingEvents(appContext); 1082 /* 1083 * This synchronized block is to secure that the event dispatch 1084 * thread won't die in the middle of posting a new event to the 1085 * associated event queue. It is important because we notify 1086 * that the event dispatch thread is busy after posting a new event 1087 * to its queue, so the EventQueue.dispatchThread reference must 1088 * be valid at that point. 1089 */ 1090 pushPopLock.lock(); 1091 try { 1092 if (edt == dispatchThread) { 1093 dispatchThread = null; 1094 } 1095 AWTAutoShutdown.getInstance().notifyThreadFree(edt); 1096 } finally { 1097 pushPopLock.unlock(); 1098 } 1099 } 1100 1101 /* 1102 * Gets the <code>EventDispatchThread</code> for this 1103 * <code>EventQueue</code>. 1104 * @return the event dispatch thread associated with this event queue 1105 * or <code>null</code> if this event queue doesn't have a 1106 * working thread associated with it 1107 * @see java.awt.EventQueue#initDispatchThread 1108 * @see java.awt.EventQueue#detachDispatchThread 1109 */ 1110 final EventDispatchThread getDispatchThread() { 1111 pushPopLock.lock(); 1112 try { 1113 return dispatchThread; 1114 } finally { 1115 pushPopLock.unlock(); | 1076 1077 final void detachDispatchThread(EventDispatchThread edt) { 1078 /* 1079 * Minimize discard possibility for non-posted events 1080 */ 1081 SunToolkit.flushPendingEvents(appContext); 1082 /* 1083 * This synchronized block is to secure that the event dispatch 1084 * thread won't die in the middle of posting a new event to the 1085 * associated event queue. It is important because we notify 1086 * that the event dispatch thread is busy after posting a new event 1087 * to its queue, so the EventQueue.dispatchThread reference must 1088 * be valid at that point. 1089 */ 1090 pushPopLock.lock(); 1091 try { 1092 if (edt == dispatchThread) { 1093 dispatchThread = null; 1094 } 1095 AWTAutoShutdown.getInstance().notifyThreadFree(edt); 1096 /* 1097 * Event was posted after EDT events pumping had stopped, so start 1098 * another EDT to handle this event 1099 */ 1100 if (peekEvent() != null) { 1101 initDispatchThread(); 1102 } 1103 } finally { 1104 pushPopLock.unlock(); 1105 } 1106 } 1107 1108 /* 1109 * Gets the <code>EventDispatchThread</code> for this 1110 * <code>EventQueue</code>. 1111 * @return the event dispatch thread associated with this event queue 1112 * or <code>null</code> if this event queue doesn't have a 1113 * working thread associated with it 1114 * @see java.awt.EventQueue#initDispatchThread 1115 * @see java.awt.EventQueue#detachDispatchThread 1116 */ 1117 final EventDispatchThread getDispatchThread() { 1118 pushPopLock.lock(); 1119 try { 1120 return dispatchThread; 1121 } finally { 1122 pushPopLock.unlock(); |