Loading indicator force

How would I force the appearance of a loading indicator before showing main UI view (initialization) for a few seconds?

One solution is to add a ProgressBar to the view and then start the main view initialization in a separate thread, and then hide the progress bar once the thread finishes.

Hi I am sorry, but I am quite new to Vaadin. Can you give a little bit of example code?