Once the GUI is visible, most programs are driven by events such as button actions or mouse clicks, which are always handled in the event-dispatching thread. These requests can come at any time, and they result in one of the server's methods being invoked in some possibly unknown thread. By executing the GUI update code in the event-dispatching thread. This method returns immediately, without waiting for the code to execute. The invokeLater method returns immediately, without waiting for the event-dispatching thread to execute the code.
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.