Method invokeLater(Runnable doRun) causes doRun.run() to be executed asynchronously on the AWT event dispatching thread. This will happen after all pending AWT events have been processed.
This method should be used when an application thread needs to update the GUI. In the following example the invokeLater call queues the Runnable object pickHighBetaStock on the event dispatching thread and then prints a message.
Runnable pickHighBetaStock = new Runnable() {
public void run() {
System.out.println("High beta Stockpicked by " + Thread.currentThread());
}
};
SwingUtilities.invokeLater(pickHighBetaStock);
System.out.println("This might well be displayed before the other message. if Event-dispatcher thread is busy");