itun itun - 1 year ago 132
Java Question

Eclipse RCP multithreading

I have an eclipse rcp application. And I have a command when this command is executing. I need to start a thread. After execution of this thread GUI must be updated. But I suppose that this thread or other non-SWT thread cannot update GUI. But it seems reasonable. When I was trying to do that I got

Exception in thread "Thread-5" org.eclipse.swt.SWTException: Invalid thread access
. How I can make this goal?


Using SWT you need to have anything that updates the GUI be done on the main thread, or in Eclipse, it's called the UI thread (it's the same thread). You are getting this error because you are trying to access an SWT object on another thread. Consider using Display.syncExec() or Display.asyncExec() to move the SWT related processing to the main thread. You want to be careful with syncExec() that you don't cause a deadlock.