Add to Patton's answer . Although I am not an expert on this topic, I post my understanding after carefully reading the document and read this post from Roland Krueger.
Result: controversial issue
While I do not know the exact answer to your question, I believe that the question is controversial.
➡ Let Vaadin 7.1 and later will automatically commit . Doc says an automatic blocking route is preferable to manual blocking.
Non-issue on main thread
If you use VaadinSession from the normal Vaadin main UI thread, then explicit locking is not required. Vaadin automatically blocks VaadinSession as needed when working in the main thread.
All your application state is stored in this session object, so Vaadin regularly accesses and protects this session.
Other topics
Locking is only a problem when accessing VaadinSession from the background thread from the thread you started.
Even so, Vaadin provides a couple of options when the lock is processed automatically if you pass Runnable to any of these access methods:
If your code only affects VaadinSession, without touching any UI object (user interface, layouts, widget components, etc.), use VaadinSession.access() . On the other hand, if your code affects any user interface objects, as well as directly on VaadinSession, use the second, UI.access() .
Manual lock without function
Therefore, when you can control the lock during access to VaadinSession, you only need to do this in the background thread and for some reason you do not want to call the access method. But I can not imagine such a reason.
For a more detailed discussion and the groovy diagram I did, see this similar question, how to put data in a session variable and get data on another page in vaadin? .