Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Refresher or java.util.Timer
Hi
I have a situation that I have to poll the backend every X msec and the update the UI with the fresh backend data.
Only ONE user (the one that activates this specific window) should get the refreshed data. (The refresh action is actually changing the value of a Label).
Here is my question:
Should I go with Refresher or java.util.Timer will be enough?
Thanks
Avishay
Timer run on server side which can not refresh the UI automatically. It will also not provide any thread safety if you decide to change the UI (you need to synchronize yourself)
Refresher runs on both sides (a script on client and a listener on server) and so can refresh the UI. As it runs into main Vaadin thread there is no risk of race condition here.
So in your case, you should go with the refresher.
For more details on polling, pushing and background UI updates see this sticky for a good explanation.