There are two methods in the SWT Display class, syncExec and aSyncExec. They are used when you have a thread that is not a user interface thread that somehow wants to update the interface. Basically, when you name them, you basically tell the user interface thread that you have something that you want to do when it has a chance. In this way, the UI thread will continue its current work, and at some point it will do what you requested. When he does this, it will always change depending on what other work the user interface thread should do at this time.
The difference between aSyncExec and syncExec is whether the code calling it will wait for the execution to complete. If you call aSyncExec, the next statement in the calling thread will execute immediately. If you call syncExec, then your calling thread will sit and wait for the user interface thread to actually execute the code and return. By the time, how much time is required to execute syncExec, you therefore cannot determine how much time is required to execute the execution method, but also how long before the user interface thread starts to run it.
Do not succumb to replacing syncExec with aSyncExec. If you take the time to run aSyncExec, you will find it even faster. But this is because all you need is the time it takes to tell the user interface thread that you have something for it (not how long it takes to complete it).
Davejohnston
source share