Why do people run Java GUI's on the Event Queue

Posted by asmo on Stack Overflow See other posts from Stack Overflow or by asmo
Published on 2010-06-10T20:19:01Z Indexed on 2010/06/10 21:13 UTC
Read the original article Hit count: 172

Filed under:
|
|
|
|

In Java, to create and show a new JFrame, I simply do this:

public static void main(String[] args)
{
   new JFrame().setVisible(true);
}

However, I have seen many people doing it like this:

public static void main(String[] args)
{
  EventQueue.invokeLater(new Runnable()
  {
       public void run()
       {
           new JFrame().setVisible(true);
       }
  });
}

Why? Are there any advantages?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing