This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman 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 Elasticsearch in Action this week in the Big Data 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: 807

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: 2261
Use a Swing Worker.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

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
I agree. Here's the link:
subject: retrieving event dispatch thread