Search code examples
javaswingawtevent-dispatch-thread

When does the EDT start?


I was wondering when does the event dispatch thread start in Java.

  1. Is it the main thread, or is it started in Window/Frame constructor?

  2. Is it started by JVM if it detects usage of AWT/Swing?


Solution

  • Main thread is not the EDT thread. EDT thread (and some another related threads) is started automatically when the first GUI event is posted (for example: you show first window or you use the method SwingUtilities.invokeLater). For more info see the class EventQueue.