0

what is difference between event dispatch thread and any normal thread like main thread in creation swing compoments and handling events , what is features of event dispatch thread over main thread

by coding , what is difference between these two Piece of code :

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

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

what does EDT do that can not be done by main thread or any other normal thread ?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user1841718
  • 187
  • 1
  • 4
  • 15
  • In the first case, the UI is run on a separate thread and won't hung up if you make some time consuming task in it. The latter will and your UI will stuck look non responsive and pale! – Abraham Apr 11 '13 at 14:43
  • 1
    EDT is a thread just like any other thread. Its just used specifically for Swing components to avoid GUI lock up. For more complex processes on the GUI you use Worker threads. Check out the following: http://docs.oracle.com/javase/tutorial/uiswing/concurrency/ – Nico Apr 11 '13 at 14:54
  • take a look at http://stackoverflow.com/q/15395522/217324 – Nathan Hughes Apr 12 '13 at 14:15

0 Answers0