From: dman <ds...@ri...> - 2001-07-23 14:53:25
|
On Mon, Jul 23, 2001 at 12:20:38PM +0200, Kevin McNamee wrote: | Thanks, your example was very useful. | | If I call MyThread().run() and I am not in the event-dispatching thread, | everything works fine. I can do long tasks and call invokeLater to update | the GUI with each result. | | If I call MyThread().run() when a button is pressed, then | isEventDispatchThread() returns true and the updater function is called | directly. This is because button events are handled in the | event-dispatching thread, but the result is that the GUI is not updated | until the button event finishes :( | | What I am doing wrong? You want to /start/, not /run/ MyThread from the button event handler. When you start() a thread it actually creates the new thread, then runs it. The run() method doesn't return until your long work is done, but start() returns immediately. HTH, -D |