thread execution and gui update

Hi,

I want to update my gui and thereafter I want to execute a thread. But the thread is always executed before the gui is updated by the program. Here is my code:


	public void getWaitTime()
	{

	      WaitThread t = new WaitThread();
	      t.start();
	      try {
	        Thread.sleep(10000);
	      } catch (InterruptedException e) {

	      }
	
	      try {
	       t.join();
	      } catch (java.lang.InterruptedException e) {}
	      this.proceedUser();
	     }

public void proceedUser()
 {
		if( check the db if this case is allowed )
		{
			labelWaitMessage.setValue("Just wait some minutes...You are being redirected.");
			l1.addComponent(getUserWaitView(buttonUpdateView,labelWaitMessage));
			
			getWaitTime();
		}

}

How can I change the gui with l1.addComponent(…) and after this execute the thread?

This thread should help you:
Updating UI from another thread
. In short, you need a push or pull solution to get updates to browser and you need to syncronize UI changes made in an external thread against a correct Application instance.

Since you’re doing a join() on the thread, you’re waiting for it to finish before continuing. It’s like you’re not using a separate thread at all. Kick off that thread, and then ignore it. Let the other (new) thread do the work to change your GUI, and use push/pull like in the article to make the UI changes apparent to the user.

Don’t forget to synchronize on whatever data you’re changing since your background thread could be accessing it at the same time an http request is.

Cheers,
Bobby