I want to make a GUI application in which I want to do something continuously (i.e. in while loop) in a different thread, until the user presses a button. In this other thread, I am accessing GUI elements and hence I have to use SwingUtilities.invokeLater() for this thread. But since this thread never ends, the Event Dispatching Thread's event handler for the button would never be called. How to handle this situation ?