Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Eclipse beginner threading question...

Russ Rufer wrote:

Hi Horst,

Display.asyncExec(Runnable runnable) should be analogous to SwingUtilities.invokeLater(Runnable runnable). From the Display javadocs:

* Causes the <code>run()</code> method of the runnable to
* be invoked by the user-interface thread at the next
* reasonable opportunity. The caller of this method continues
* to run in parallel, and is not notified when the
* runnable has completed.

The purpose is the same as SwingUtilities.invokeLater(), to request that the gui thread execute some code (the request being queued from another thread). Maybe there's another cause for your exception?

- Russ

Hi Russ,

Thanks for your reply. But I am still stuck. My problem is that I have a listener and it gets notifed when a change has occurred in the model. The listener is being notified in a non gui thread. So when I am notified of the change it is on a non ui thread. I then am trying to call the line of code you have suggested


from this non ui thread. It then crashes because evidently this is not legal. I guess what I am looking for is some utility or method that I can say run this on the UI thread but I can call the utility or method from this background thread. Something like Swingutilities,.invokeLater in swing.

-- Horst

eclipse-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Hi Russ,,

I think I have found a solution. I have called this

Display.getDefault().asyncExec(new Runnable() {
           public void run() {

before I tried this I tried to get access to the Display object thru the IWorkBench like this

IWorkbench wb = PlatformUI.getWorkbench();
       IWorkbenchWindow w = wb.getActiveWorkbenchWindow();
       IWorkbenchPage p = w.getActivePage();

and these calls were failing.

Looks like Display.getDefault() will create the Display object which solves the problem. But since I am new to eclipse, is this the proper
way to handle this?

Back to the top