The invokeLater method returns immediately, without waiting for the event-dispatching thread to execute the code. The invokeAndWait method is just like invokeLater , except that invokeAndWait doesn't return until the event-dispatching thread has executed the specified code. Whenever possible, you should use invokeLater instead of invokeAndWait . If you use invokeAndWait , make sure that the thread that calls invokeAndWait does not hold any locks that other threads might need while the call is occurring. If you can get away with it, avoid using threads.
Threads can be difficult to use, and they make programs harder to debug.
In general, they just aren't necessary for strictly GUI work, such as updating component properties. However, sometimes threads are necessary. To perform an operation repeatedly, usually with some predetermined period of time between operations. To wait for messages from clients. Creates a background thread to execute time-consuming operations.