I am working on a project using Eclipse RCP and Swing. I see two pairs of methods invokeLater()/invokeAndWait() and asyncExec()/syncExec() being used a lot.
From what I understand, invokeLater()/invokeAndWait() belong to Swing, and asyncExec()/syncExec() belong to Eclipse. But what is the difference between these two pairs of methods?
If they are all used to execute a task on the UI thread, is it the same UI thread that they post the task onto? Are invokeLater() and asyncExec() interchangeable?
Is there any potential pitfall (e.g. deadlock, etc.) if I'm calling e.g. syncExec() from invokeAndWait()?
Eclipse uses the SWT User Interface, this is a completely separate UI system from Swing. asyncExec()/syncExec() are part of the SWT system.
If you are writing an Eclipse RCP or plug-ins for Eclipse you should be writing SWT code.
SWT does provide a method of using Swing code but this should be a last resort.
Since they are totally different UI systems each with its own event loop invokeAndWait and syncExec are not interchangeable. It is very easy to get into a mess when there are two UI event loops running.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With