jdk/src/share/classes/java/awt/EventDispatchThread.java
changeset 4365 4ac67034e98b
parent 3938 ef327bd847c0
child 5506 202f599c92aa
equal deleted inserted replaced
4364:4b4427db3536 4365:4ac67034e98b
   102                 }
   102                 }
   103             }
   103             }
   104         } else {
   104         } else {
   105             stopEvent.dispatch();
   105             stopEvent.dispatch();
   106         }
   106         }
   107         synchronized (theQueue) {
   107 
   108             if (theQueue.getDispatchThread() == this) {
   108         theQueue.detachDispatchThread(this, false);
   109                 theQueue.detachDispatchThread();
       
   110             }
       
   111         }
       
   112     }
   109     }
   113 
   110 
   114     public void stopDispatching() {
   111     public void stopDispatching() {
   115         stopDispatchingImpl(true);
   112         stopDispatchingImpl(true);
   116     }
   113     }
   140                 public boolean evaluate() {
   137                 public boolean evaluate() {
   141                     return true;
   138                     return true;
   142                 }
   139                 }
   143             });
   140             });
   144         } finally {
   141         } finally {
   145             /*
   142             theQueue.detachDispatchThread(this, true);
   146              * This synchronized block is to secure that the event dispatch
       
   147              * thread won't die in the middle of posting a new event to the
       
   148              * associated event queue. It is important because we notify
       
   149              * that the event dispatch thread is busy after posting a new event
       
   150              * to its queue, so the EventQueue.dispatchThread reference must
       
   151              * be valid at that point.
       
   152              */
       
   153             synchronized (theQueue) {
       
   154                 if (theQueue.getDispatchThread() == this) {
       
   155                     theQueue.detachDispatchThread();
       
   156                 }
       
   157                 /*
       
   158                  * Event dispatch thread dies in case of an uncaught exception.
       
   159                  * A new event dispatch thread for this queue will be started
       
   160                  * only if a new event is posted to it. In case if no more
       
   161                  * events are posted after this thread died all events that
       
   162                  * currently are in the queue will never be dispatched.
       
   163                  */
       
   164                 /*
       
   165                  * Fix for 4648733. Check both the associated java event
       
   166                  * queue and the PostEventQueue.
       
   167                  */
       
   168                 if (theQueue.peekEvent() != null ||
       
   169                     !SunToolkit.isPostEventQueueEmpty()) {
       
   170                     theQueue.initDispatchThread();
       
   171                 }
       
   172                 AWTAutoShutdown.getInstance().notifyThreadFree(this);
       
   173             }
       
   174         }
   143         }
   175     }
   144     }
   176 
   145 
   177     void pumpEvents(Conditional cond) {
   146     void pumpEvents(Conditional cond) {
   178         pumpEvents(ANY_EVENT, cond);
   147         pumpEvents(ANY_EVENT, cond);