Content deleted Content added
m moved Event Dispatch Thread to Event dispatching thread: Wrong name. |
No edit summary |
||
Line 5:
Other application threads can execute code in the event dispatch thread by defining the code in a {{Javadoc:SE|java/lang|Runnable}} object and pass it to the {{Javadoc:SE|javax/swing|SwingUtilities}} helper class. Two methods of this class allow synchronous ({{Javadoc:SE|member=invokeAndWait(Runnable)|javax/swing|SwingUtilities|invokeAndWait(java.lang.Runnable)}}) and asynchronous ({{Javadoc:SE|member=invokeLater(Runnable)|javax/swing|SwingUtilities|invokeLater(java.lang.Runnable)}}) code execution from the EDT. The method <code>invokeAndWait()</code> should never be called from the event dispatch thread—it will throw an [[Exception handling|exception]]. The method{{Javadoc:SE|javax/swing|SwingUtilities|isEventDispatchThread()}} can be called to determine if the current thread is the event dispatching thread.
Another solution for executing code in the EDT is using the ''[[Worker pattern|worker design pattern]]''. The <code>[
== See also ==
|