java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyJFrame().setVisible(true);
}
});
I often see the above code snippet in Java Swing GUI applications. The java.awt.EventQueue
seems to serve as a global access point for the message queue which is consumed by the Event Dispatching Thread
.
My questions are:
Is the sole purpose of
java.awt.EventQueue
to serve as a global communication channel between other threads and the EDT? Any other scenarios to use it?How/When is the EDT launched?