Created
June 19, 2016 23:48
-
-
Save Vaysman/2460f23e2e62d20c89c1ec866836ee79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Causes <i>doRun.run()</i> to be executed asynchronously on the | |
* AWT event dispatching thread. This will happen after all | |
* pending AWT events have been processed. This method should | |
* be used when an application thread needs to update the GUI. | |
* In the following example the <code>invokeLater</code> call queues | |
* the <code>Runnable</code> object <code>doHelloWorld</code> | |
* on the event dispatching thread and | |
* then prints a message. | |
* <pre> | |
* Runnable doHelloWorld = new Runnable() { | |
* public void run() { | |
* System.out.println("Hello World on " + Thread.currentThread()); | |
* } | |
* }; | |
* | |
* SwingUtilities.invokeLater(doHelloWorld); | |
* System.out.println("This might well be displayed before the other message."); | |
* </pre> | |
* If invokeLater is called from the event dispatching thread -- | |
* for example, from a JButton's ActionListener -- the <i>doRun.run()</i> will | |
* still be deferred until all pending events have been processed. | |
* Note that if the <i>doRun.run()</i> throws an uncaught exception | |
* the event dispatching thread will unwind (not the current thread). | |
* <p> | |
* Additional documentation and examples for this method can be | |
* found in | |
* <A HREF="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html">Concurrency in Swing</a>. | |
* <p> | |
* As of 1.3 this method is just a cover for <code>java.awt.EventQueue.invokeLater()</code>. | |
* <p> | |
* Unlike the rest of Swing, this method can be invoked from any thread. | |
* | |
* @see #invokeAndWait | |
*/ | |
public static void invokeLater(Runnable doRun) { | |
EventQueue.invokeLater(doRun); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment