This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes retrieving event dispatch thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "retrieving event dispatch thread" Watch "retrieving event dispatch thread" New topic

retrieving event dispatch thread

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804

Hi Java Ranchers!

I have two threads. The first one compute some tasks and after that it call Event Dispatch Thread to present that task. Event Dispatch Thread do it, but the computations thread do another computations and Event Dispatch Thread is too slow to present the data.

I want to wait for the Event Dispatch Thread and then perform some computation. There is join() function, but how can I get a referece to the Event Dispatch Thread?

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2180
Use a Swing Worker.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19685

You definitely do not want to join on the EDT; it won't stop when your Runnable is finished.

If you can't use SwingWorker you can try EventQueue.invokeAndWait. This blocks until your Runnable has ended (and therefore cannot be run from the EDT itself or it's a 100% guaranteed deadlock).

How To Ask Questions How To Answer Questions
jQuery in Action, 2nd edition
subject: retrieving event dispatch thread