UI.access() and accessing Session-Global Data

Hi Guys,

I’m wondering what is the best practice for accessing the right session-global data, when using
[color=#5b7f8b]

otherUI.access(()->doSomething());

[/color]
If i use

VaadinSession.getCurrent().getAttribute("myData") I get the data of the false UI.
So what is the best way. Should I pass it as and parameter like

final Data myData;
otherUI.access(()->doSomething(myData));

or is there the right way to acces the global data of the otherUi within my Runnable()?
I would prefer the second way, but i haven’t figured yet how to access the right data.

Thanks.