Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Event dispatching thread
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Requests from other threads === Other application threads can pass some code to be executed in the event dispatching thread by means of {{Javadoc:SE|javax/swing|SwingUtilities|module=java.desktop}} helper classes (or {{Javadoc:SE|java/awt|EventQueue|module=java.desktop}} if you are doing [[Abstract Window Toolkit|AWT]]). The submitted code must be wrapped with a {{Javadoc:SE|java/lang|Runnable}} object. Two methods of these classes allow: * synchronous code execution ({{Javadoc:SE|member=invokeAndWait(Runnable)|javax/swing|SwingUtilities|invokeAndWait(java.lang.Runnable)|module=java.desktop}} or {{Javadoc:SE|member=invokeAndWait(Runnable)|java/awt|EventQueue|invokeAndWait(java.lang.Runnable)|module=java.desktop}}) * and asynchronous code execution ({{Javadoc:SE|member=invokeLater(Runnable)|javax/swing|SwingUtilities|invokeLater(java.lang.Runnable)|module=java.desktop}} or {{Javadoc:SE|member=invokeLater(Runnable)|java/awt|EventQueue|invokeLater(java.lang.Runnable)|module=java.desktop}}) from the event dispatching thread. The method <code>invokeAndWait()</code> should never be called from the event dispatching thread—it will throw an [[Exception handling|exception]]. The method {{Javadoc:SE|javax/swing|SwingUtilities|isEventDispatchThread()|module=java.desktop}} or {{Javadoc:SE|java/awt|EventQueue|isDispatchThread()|module=java.desktop}} can be called to determine if the current thread is the event dispatching thread. The code supplied by means of the <code>invokeLater</code> and <code>invokeAndWait</code> to the EDT must be as quick as possible to prevent freezing. They are normally intended to deliver the result of a lengthy computation to the GUI (user).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)