Design Question -updating session and UIs from an external thread in Vaadin

I have an app that uses Vaadin push to send data to multiple sessions every second. The data is continuously produced upstream in another thread by a DataService class outside of the Vaadin framework. Each subclass of Vaadin.UI has its own DataService reference created by init(). DataService makes the latest data available to the UI. All DataService instances (one per UI) provide the same data originating from the same source. All the Vaadin sessions must push the same data to their UIs (session scope).

I’m trying to migrate the app to use Vaadin 7 and perform the data updates efficiently for each session and for each UI.

One way may be to make each UI an Observer of its own DataService instance, and then whenever the UI isVisible, let update(Observable) call VaadinSession.access(new Runnable() …grab the latest data from the DataService thread and perform the UI update… ). But then the access method would be called for all visible UIs concurrently. The access does not appear to be synchronized w.r.t. VaadinSession. I don’t know how safe or how efficient this way of doing things is.

Is there a better/safer way to update all the sessions and UIs simultaneously with a minimum number of calls to access?
Looking for ideas…
Many thanks.

You should perform all data processing tasks outside access call. And you can do all this in single thread (if all UIs share data), or on own thread for each UI (if data is different). After data is processed, thread can pass it to each active UI instance (requiring that data) via access call. This way locking is limited only to UI changes, that require the locking.

So if your DataService is shared between all UIs, just perform data magic to it. After this update UI state of all listeners via access call. UI access is same as requiring session lock before performing the runnable (simplified). You want to have own lock for each UI, to not lock all sessions while updating just one.