I am having an eclipse View. Inside the view I added a Table. Now I am calling a thread from run method of the view using asyncExec.
My View class is like –
public class SampleViewAction implements IWorkbenchWindowActionDelegate{
Thread t;
int Count;
@Override
public void run(IAction arg0) {
}
}
Now I added a thread like this –
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
new UDPReadThread();
}
});
Where UDPReadThread is a class extends a thread where in UDPReadThread ‘s constructor I started the thread.
But I am getting invalid Thread exception.
How to resolve the issue.
Similar to AWT and the EventDispatchThread, SWT must process everything in the UI thread.
Your
SampleViewActionis run on the UI thread already, in response to a menu or tool item selection.It looks like your problem comes from then using an
asyncExec(*)which will post the runnable to be run on the UI thread (which delays it), and starting a new thread from thatasyncExecRunnable. You may as well simply start your thread, and get rid of thatasyncExec.Your
UDPReadThreadis not the UI thread. If you need to update UI widgets fromUDPReadThread, that’s the code that needs theasyncExec:Just as an aside, you should not subclass
Threadunless you really are extending threads capabilities. The normal pattern when you just want to start another thread:You can get more information on the display thread from http://www.eclipse.org/swt/faq.php#uithread