thread execution and gui update


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();
	      try {
	      } catch (InterruptedException e) {

	      try {
	      } catch (java.lang.InterruptedException e) {}

public void proceedUser()
		if( check the db if this case is allowed )
			labelWaitMessage.setValue("Just wait some minutes...You are being redirected.");


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.