Thread Safety

I am wondering what kind of thread-safety issues one has to take into account when using the Vaadin framework. The first thing I noticed, and that I am not sure of, is the following: Using Vaadin 8.1, I am setting up a grid backed by an in-memory collection of some custom objects like this:

[code]
public class MyView implements View {
private Grid grid = new Grid<>();
public MyView() {
ListDataProvider dataProvider = DataProvider.ofCollection(createSomeObjects());
this.grid.setDataProvider(dataProvider);
// attach grid to view …
}
// @Override View#enter etc. …
}

public class MyObject {
// just a POJO …, no synchronization or anything
private String someString;
public void setSomeString(String s) {this.someString = s;}
public String getSomeString() {
LOGGER.debug(“getter called”);
return this.someString;
}
}
[/code]Now, if I use the scrollbar of the grid, I can see that different threads are entering the getSomeString() method. This is not so surprising, as probably each scrollbar interaction is handled with a separate request running in a different thread, but I could not find any information telling me whether the access into MyObject is synchronized. Is there anything that needs to be done regarding thread-safety in this scenario ?

Java application servers use multiple threads to serve requests, so different requests may end up being handled by different threads. Vaadin Framework locks the session and the UI while procesing an HTTP request for it, so there are no problems in normal operation. However, if the application itself uses background threads, UI.access() should be used around any access to the UI in a background threads to ensure proper locking, context setup and thread safety.

Ok, thanks. So in the above example the access to MyObject is thread safe, because the vaadin session is locked (?). But if MyObject was in the application scope, I would have to assure a thread safe access myself ? I will also look at UI.access().