< prev index next >

src/java.desktop/share/classes/java/awt/doc-files/AWTThreadIssues.html

Print this page

        

*** 1,7 **** <!-- ! Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation. Oracle designates this --- 1,13 ---- + <!doctype html> + <html lang="en"> + <head> + <meta charset="utf-8"/> + <title>AWT Threading Issues</title> + </head> <!-- ! Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 only, as published by the Free Software Foundation. Oracle designates this
*** 21,49 **** Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA or visit www.oracle.com if you need additional information or have any questions. --> ! <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ! <html> ! <head> ! <title></title> ! </head> ! <body bgcolor=white> ! <h1 align=center>AWT Threading Issues</h1> ! <a name="ListenersThreads"></a> <h2>Listeners and threads</h2> Unless otherwise noted all AWT listeners are notified on the event dispatch thread. It is safe to remove/add listeners from any thread during dispatching, but the changes only effect subsequent notification. <br>For example, if a key listeners is added from another key listener, the newly added listener is only notified on subsequent key events. ! <a name="Autoshutdown"></a> <h2>Auto-shutdown</h2> According to <cite>The Java&trade; Virtual Machine Specification</cite>, sections 2.17.9 and 2.19, --- 27,50 ---- Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA or visit www.oracle.com if you need additional information or have any questions. --> ! <body> ! <h1>AWT Threading Issues</h1> ! <a id="ListenersThreads"></a> <h2>Listeners and threads</h2> Unless otherwise noted all AWT listeners are notified on the event dispatch thread. It is safe to remove/add listeners from any thread during dispatching, but the changes only effect subsequent notification. <br>For example, if a key listeners is added from another key listener, the newly added listener is only notified on subsequent key events. ! <a id="Autoshutdown"></a> <h2>Auto-shutdown</h2> According to <cite>The Java&trade; Virtual Machine Specification</cite>, sections 2.17.9 and 2.19,
*** 82,96 **** <li> <code>AWTEvents</code> which were actually enqueued to a particular <code>EventQueue</code> (note that events being posted to the <code>EventQueue</code> can be coalesced) are dispatched: <ul> ! <li> Sequentially. ! <dl><dd> That is, it is not permitted that several events from this queue are dispatched simultaneously. </dd></dl> ! <li> In the same order as they are enqueued. ! <dl><dd> That is, if <code>AWTEvent</code>&nbsp;A is enqueued to the <code>EventQueue</code> before <code>AWTEvent</code>&nbsp;B then event B will not be dispatched before event A.</dd></dl> </ul> <li> There is at least one alive non-daemon thread while there is at --- 83,99 ---- <li> <code>AWTEvents</code> which were actually enqueued to a particular <code>EventQueue</code> (note that events being posted to the <code>EventQueue</code> can be coalesced) are dispatched: <ul> ! <li> ! <dl><dt>Sequentially. ! <dd> That is, it is not permitted that several events from this queue are dispatched simultaneously. </dd></dl> ! <li> ! <dl><dt>In the same order as they are enqueued. ! <dd> That is, if <code>AWTEvent</code>&nbsp;A is enqueued to the <code>EventQueue</code> before <code>AWTEvent</code>&nbsp;B then event B will not be dispatched before event A.</dd></dl> </ul> <li> There is at least one alive non-daemon thread while there is at
*** 166,176 **** On the other hand, if you require the JVM to continue running even after the application has made all components undisplayable you should start a non-daemon thread that blocks forever. <pre> ! <...> Runnable r = new Runnable() { public void run() { Object o = new Object(); try { synchronized (o) { --- 169,179 ---- On the other hand, if you require the JVM to continue running even after the application has made all components undisplayable you should start a non-daemon thread that blocks forever. <pre> ! &lt;...&gt; Runnable r = new Runnable() { public void run() { Object o = new Object(); try { synchronized (o) {
*** 181,191 **** } }; Thread t = new Thread(r); t.setDaemon(false); t.start(); ! <...> </pre> <cite>The Java&trade; Virtual Machine Specification</cite> guarantees that the JVM doesn't exit until this thread terminates. --- 184,194 ---- } }; Thread t = new Thread(r); t.setDaemon(false); t.start(); ! &lt;...&gt; </pre> <cite>The Java&trade; Virtual Machine Specification</cite> guarantees that the JVM doesn't exit until this thread terminates.
< prev index next >