src/share/classes/sun/awt/AWTAutoShutdown.java

Print this page




 215         synchronized (activationLock) {
 216             synchronized (mainLock) {
 217                 if (!isReadyToShutdown() && blockerThread == null) {
 218                     activateBlockerThread();
 219                 } else {
 220                     mainLock.notifyAll();
 221                     timeoutPassed = false;
 222                 }
 223             }
 224         }
 225     }
 226 
 227     /**
 228      * Determine whether AWT is currently in ready-to-shutdown state.
 229      * AWT is considered to be in ready-to-shutdown state if
 230      * <code>peerMap</code> is empty and <code>toolkitThreadBusy</code>
 231      * is false and <code>busyThreadSet</code> is empty.
 232      *
 233      * @return true if AWT is in ready-to-shutdown state.
 234      */
 235     private boolean isReadyToShutdown() {





 236         return (!toolkitThreadBusy &&
 237                  peerMap.isEmpty() &&
 238                  busyThreadSet.isEmpty());

 239     }
 240 
 241     /**
 242      * Notify about the toolkit thread state change.
 243      *
 244      * @param busy true if the toolkit thread state changes from idle
 245      *             to busy.
 246      * @see     AWTAutoShutdown#notifyToolkitThreadBusy
 247      * @see     AWTAutoShutdown#notifyToolkitThreadFree
 248      * @see     AWTAutoShutdown#isReadyToShutdown
 249      */
 250     private void setToolkitBusy(final boolean busy) {
 251         if (busy != toolkitThreadBusy) {
 252             synchronized (activationLock) {
 253                 synchronized (mainLock) {
 254                     if (busy != toolkitThreadBusy) {
 255                         if (busy) {
 256                             if (blockerThread == null) {
 257                                 activateBlockerThread();
 258                             } else if (isReadyToShutdown()) {




 215         synchronized (activationLock) {
 216             synchronized (mainLock) {
 217                 if (!isReadyToShutdown() && blockerThread == null) {
 218                     activateBlockerThread();
 219                 } else {
 220                     mainLock.notifyAll();
 221                     timeoutPassed = false;
 222                 }
 223             }
 224         }
 225     }
 226 
 227     /**
 228      * Determine whether AWT is currently in ready-to-shutdown state.
 229      * AWT is considered to be in ready-to-shutdown state if
 230      * <code>peerMap</code> is empty and <code>toolkitThreadBusy</code>
 231      * is false and <code>busyThreadSet</code> is empty.
 232      *
 233      * @return true if AWT is in ready-to-shutdown state.
 234      */
 235     public boolean isReadyToShutdown() {
 236         // We need to synchronize here since the method is public.
 237         // The peerMap states it wants activationLock as well,
 238         // but run() doesn't use it when calling this method,
 239         // so we won't either.
 240         synchronized (mainLock) {
 241             return (!toolkitThreadBusy &&
 242                     peerMap.isEmpty() &&
 243                     busyThreadSet.isEmpty());
 244         }
 245     }
 246 
 247     /**
 248      * Notify about the toolkit thread state change.
 249      *
 250      * @param busy true if the toolkit thread state changes from idle
 251      *             to busy.
 252      * @see     AWTAutoShutdown#notifyToolkitThreadBusy
 253      * @see     AWTAutoShutdown#notifyToolkitThreadFree
 254      * @see     AWTAutoShutdown#isReadyToShutdown
 255      */
 256     private void setToolkitBusy(final boolean busy) {
 257         if (busy != toolkitThreadBusy) {
 258             synchronized (activationLock) {
 259                 synchronized (mainLock) {
 260                     if (busy != toolkitThreadBusy) {
 261                         if (busy) {
 262                             if (blockerThread == null) {
 263                                 activateBlockerThread();
 264                             } else if (isReadyToShutdown()) {