Single Thread SWT Problem

I ran into a problem when using streaming for the first time. In the SWT program in the main thread, I created a graphical interface and opened a shell, and then I started to launch a new thread to start some logic in the model and in the model in a certain state there is a method that is called in the GUI class ... and here the problem is called in second thread, while I want it to be called in the main thread, or at least execute it in the main thread

How can I solve this problem? Thank,

+3
source share
2 answers

External threads cannot access the graphical interface. Check it out display.asyncExec.

+3

asyncExec syncExec Display, runnable :

// do stuff in a background thread

// ...then schedule job to run in main thread
display.asyncExec(new Runnable() {
   ...
});

syncExec asyncExec (UI) . , asyncExec , syncExec , .

+3

Source: https://habr.com/ru/post/1735344/


All Articles