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

Print this page




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.AWTEvent;
  29 
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import java.util.HashSet;
  33 import java.util.IdentityHashMap;
  34 import java.util.Map;
  35 import java.util.Set;
  36 
  37 import sun.util.logging.PlatformLogger;
  38 import sun.misc.ThreadGroupUtils;
  39 
  40 /**
  41  * This class is to let AWT shutdown automatically when a user is done
  42  * with AWT. It tracks AWT state using the following parameters:
  43  * <ul>
  44  * <li><code>peerMap</code> - the map between the existing peer objects
  45  *     and their associated targets
  46  * <li><code>toolkitThreadBusy</code> - whether the toolkit thread
  47  *     is waiting for a new native event to appear in its queue
  48  *     or is dispatching an event
  49  * <li><code>busyThreadSet</code> - a set of all the event dispatch
  50  *     threads that are busy at this moment, i.e. those that are not
  51  *     waiting for a new event to appear in their event queue.
  52  * </ul><p>
  53  * AWT is considered to be in ready-to-shutdown state when
  54  * <code>peerMap</code> is empty and <code>toolkitThreadBusy</code>
  55  * is false and <code>busyThreadSet</code> is empty.
  56  * The internal AWTAutoShutdown logic secures that the single non-daemon
  57  * thread (<code>blockerThread</code>) is running when AWT is not in
  58  * ready-to-shutdown state. This blocker thread is to prevent AWT from




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import java.awt.AWTEvent;
  29 
  30 import java.security.AccessController;
  31 import java.security.PrivilegedAction;
  32 import java.util.HashSet;
  33 import java.util.IdentityHashMap;
  34 import java.util.Map;
  35 import java.util.Set;
  36 
  37 import sun.util.logging.PlatformLogger;
  38 import sun.awt.util.ThreadGroupUtils;
  39 
  40 /**
  41  * This class is to let AWT shutdown automatically when a user is done
  42  * with AWT. It tracks AWT state using the following parameters:
  43  * <ul>
  44  * <li><code>peerMap</code> - the map between the existing peer objects
  45  *     and their associated targets
  46  * <li><code>toolkitThreadBusy</code> - whether the toolkit thread
  47  *     is waiting for a new native event to appear in its queue
  48  *     or is dispatching an event
  49  * <li><code>busyThreadSet</code> - a set of all the event dispatch
  50  *     threads that are busy at this moment, i.e. those that are not
  51  *     waiting for a new event to appear in their event queue.
  52  * </ul><p>
  53  * AWT is considered to be in ready-to-shutdown state when
  54  * <code>peerMap</code> is empty and <code>toolkitThreadBusy</code>
  55  * is false and <code>busyThreadSet</code> is empty.
  56  * The internal AWTAutoShutdown logic secures that the single non-daemon
  57  * thread (<code>blockerThread</code>) is running when AWT is not in
  58  * ready-to-shutdown state. This blocker thread is to prevent AWT from