Clarification: access vs. accessSynchronously

Preconditions: Some other thread has locked UI.

Which of these should be used to display a popup from a background thread:

UI.getCurrent().access(() -> {
    // display popup here
});
// some other code here, does not need result from access block

or

UI.getCurrent().accessSynchronously(() -> {
    // display popup here
});
// some other code here, does not need result from access block

Am I right to assume that accessSynchronously will not jump ahead in PendingAccessQueue (com.vaadin.flow.server.VaadinSession#pendingAccessQueue)?

As I see it, the thread that is currently locking the UI will complete its work, unlock the session and run all pending access tasks, push the changes to the UI before calling accessSynchronously. Does this mean that the first example could actually display the popup marginally faster?

I’m not familiar with accessSynchronously(), but a quick note on UI.getCurrent():

UI.getCurrent() is a threadlocal that is not set if you try to call it from a non-Vaadin thread. Consider saving a reference to the ui when the component is attached, or call component.getUI().