1
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?

smwikipedia
  • 57,565
  • 86
  • 288
  • 461
  • 2
    Question 1) is examined [here](http://stackoverflow.com/q/36904354/230513); 2) happens when an event is posted to a non-running queue. – trashgod Jun 16 '16 at 07:01

0 Answers0