Why you should never invokeAndWait from the EDT Thread

EDT is the same as AWT. All UI events in AWT are scheduled on a single thread called EDT. Basically is the thread used to process UI related events in Swing.

When you InvokeAndWait from the EDT,  you basically  invoke a task and then wait for it to be completed on the same thread . This will result in a deadlock. Your method will never return cuz you are waiting for the task and the task will never run because your method will never return. InvokeLater from the EDT works because you are not waiting for the task to be completed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s