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:

You should only use the SWT event thread to manipulate your SWT widgets. You can invoke a method on the event thread using either Display.syncExec(Runnable runnable) or Display.asyncExec(Runnable runnable) -- depending on whether you want your background thread to block.

From your MultiPageEditorPart, you should be able to do something like:

Runnable runnable = new Runnable() {
   void run () {
      // activities you want to perform in the event thread


Hope that gets you unstuck.

- Russ

Horst Heistermann wrote:


I am new to eclipse and I am having a problem with threads. I have created a MultiPageEditorPart editor. I have a background thread listening to model changes in my application. I am notified of these changes in a non -gui thread. I want to set MultiPageEditorPart as dirty whenever I receive a model change event.
So I wrote a function like this

public void setEditorModified() {
      m_bModified = true;
      if (!super.isDirty()) {

This method crashes whenever I call it from the background thread. Below is the error stack. But it is a bit misleading. From the debugger, I can see the issue is with the thread I am calling firePropertyChange() from. Can anyone tell me what is the proper way to update the dirty state from a background thread. Also, the background thread is not aware of the GUI components it only has a refer.

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

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

Back to the top