Answers

Question and Answer:

  Home  Eclipse

⟩ Why do I get the error "org.eclipse.swt.SWTException Invalid thread access"?

SWT implements a single-threaded UI model often called apartment threading. In this model, only the UI-thread can invoke UI operations. SWT strictly enforces this rule. If you try and access an SWT object from outside the UI-thread, you get the exception "org.eclipse.swt.SWTException: Invalid thread access". The following code sets the text of a label from a background thread and waits for the operation to complete: display.syncExec( new Runnable() { public void run(){ label.setText(text); } });

 158 views

More Questions for you: