1015 new EventDispatchThread(threadGroup,
1016 name,
1017 EventQueue.this);
1018 t.setContextClassLoader(classLoader);
1019 t.setPriority(Thread.NORM_PRIORITY + 1);
1020 t.setDaemon(false);
1021 return t;
1022 }
1023 }
1024 );
1025 AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
1026 dispatchThread.start();
1027 }
1028 } finally {
1029 pushPopLock.unlock();
1030 }
1031 }
1032
1033 final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
1034 /*
1035 * This synchronized block is to secure that the event dispatch
1036 * thread won't die in the middle of posting a new event to the
1037 * associated event queue. It is important because we notify
1038 * that the event dispatch thread is busy after posting a new event
1039 * to its queue, so the EventQueue.dispatchThread reference must
1040 * be valid at that point.
1041 */
1042 pushPopLock.lock();
1043 try {
1044 if (edt == dispatchThread) {
1045 /*
1046 * Don't detach the thread if any events are pending. Not
1047 * sure if it's a possible scenario, though.
1048 *
1049 * Fix for 4648733. Check both the associated java event
1050 * queue and the PostEventQueue.
1051 */
1052 if (!forceDetach && (peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) {
1053 return false;
1054 }
1055 dispatchThread = null;
1056 }
1057 AWTAutoShutdown.getInstance().notifyThreadFree(edt);
1058 return true;
1059 } finally {
1060 pushPopLock.unlock();
1061 }
1062 }
1063
1064 /*
1065 * Gets the <code>EventDispatchThread</code> for this
1066 * <code>EventQueue</code>.
1067 * @return the event dispatch thread associated with this event queue
1068 * or <code>null</code> if this event queue doesn't have a
1069 * working thread associated with it
1070 * @see java.awt.EventQueue#initDispatchThread
1071 * @see java.awt.EventQueue#detachDispatchThread
1072 */
|
1015 new EventDispatchThread(threadGroup,
1016 name,
1017 EventQueue.this);
1018 t.setContextClassLoader(classLoader);
1019 t.setPriority(Thread.NORM_PRIORITY + 1);
1020 t.setDaemon(false);
1021 return t;
1022 }
1023 }
1024 );
1025 AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
1026 dispatchThread.start();
1027 }
1028 } finally {
1029 pushPopLock.unlock();
1030 }
1031 }
1032
1033 final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
1034 /*
1035 * Minimize discard possibility for non-posted events
1036 */
1037 SunToolkit.flushPendingEvents();
1038 /*
1039 * This synchronized block is to secure that the event dispatch
1040 * thread won't die in the middle of posting a new event to the
1041 * associated event queue. It is important because we notify
1042 * that the event dispatch thread is busy after posting a new event
1043 * to its queue, so the EventQueue.dispatchThread reference must
1044 * be valid at that point.
1045 */
1046 pushPopLock.lock();
1047 try {
1048 if (edt == dispatchThread) {
1049 /*
1050 * Don't detach the thread if any events are pending. Not
1051 * sure if it's a possible scenario, though.
1052 *
1053 * Fix for 4648733. Check both the associated java event
1054 * queue and the PostEventQueue.
1055 */
1056 if (!forceDetach && (peekEvent() != null)) {
1057 return false;
1058 }
1059 dispatchThread = null;
1060 }
1061 AWTAutoShutdown.getInstance().notifyThreadFree(edt);
1062 return true;
1063 } finally {
1064 pushPopLock.unlock();
1065 }
1066 }
1067
1068 /*
1069 * Gets the <code>EventDispatchThread</code> for this
1070 * <code>EventQueue</code>.
1071 * @return the event dispatch thread associated with this event queue
1072 * or <code>null</code> if this event queue doesn't have a
1073 * working thread associated with it
1074 * @see java.awt.EventQueue#initDispatchThread
1075 * @see java.awt.EventQueue#detachDispatchThread
1076 */
|