Do you have to lock the session before calling removeAll() in a layout?

I’m getting an exception from the RemoveAll() statement in the displayWod method. I understand the need to lock the session in the hourly method when I get a session attribute, buy why the need to lock it just to remove components?

 @Scheduled(cron = "0 0 * * * ?")
    public void hourly() {
        String userTimezone = null;
        if (vaadinSession != null) {
            try {
                userTimezone = (String) vaadinSession.getAttribute(USER_TIMEZONE);
            } finally {
        if (userTimezone != null) {
            ZoneId zoneId = ZoneId.of(userTimezone);
            ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(, zoneId);
            if (zonedDateTime.getHour() == 0)
                wodView.displayWod(zonedDateTime); //line 64
 public void displayWod(ZonedDateTime zonedDateTime) {
        removeAll(); //line 44
		// additional code omitted
java.lang.IllegalStateException: Cannot access state in VaadinSession or UI without locking the session.
	at com.vaadin.flow.server.VaadinSession.checkHasLock( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.server.VaadinSession.checkHasLock( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.StateTree.checkHasLock( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.StateTree.markAsDirty( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.StateNode.markAsDirty( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.nodefeature.NodeList.addChange( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.nodefeature.NodeList.clear( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.nodefeature.StateNodeNodeList.clear( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.internal.nodefeature.ElementChildrenList.clear( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.dom.impl.AbstractNodeStateProvider.removeAllChildren( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.dom.Node.removeAllChildren( ~[flow-server-2.1.9.jar:2.1.9]

	at com.vaadin.flow.component.HasComponents.removeAll( ~[flow-server-2.1.9.jar:2.1.9]

	at com.wodiq.ui.views.WodView.displayWod( ~[classes/:na]

	at com.wodiq.logic.Cron.hourly( ~[classes/:na]

Yes, it’s needed to ensure no more than just one thread modifies UI elements concurrently.
I don’t know the exact details but just think about an ArrayList or a HashSet with children elements. If two threads concurrently remove or add children to the map the Array/HashSet would throw an ConcurrentModificationException.

Therefore some sort of synchronization is needed. The contract is that all UI/Session work is being done in threads with a locked UI.

for more info on this topic.