title: Thread wait in Android
body: <p>i have one problem with handling the thread in android ,in my class i have to create one thread which create some UI after that thread finish i will get some value ,here i want to wait my Main Process until the thread complete it process but when i put wait() or notify in Main process  thread does not show the  UI  in my application</p>
  
  <p>this is sample code</p>
  
  <pre><code>    protected void onCreate(Bundle savedInstanceState) {
  
           downloadThread = new MyThread(this);
              downloadThread.start();
  
              synchronized(this){  
                  try {
                      this.wait();
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
  
   String test=Recognition.gettemp();
      public class MyThread extends Thread {
          private Recognition recognition;
  
          public MyThread(Recognition recognition) {
              this.recognition = recognition;
              // TODO Auto-generated constructor stub
          }
  
          @Override
          public void run() {
      synchronized(this)
  
              {                
  
                          handler.post(new MyRunnable());
  
                  }
  
                  notifyAll();
              }
          }
      }
      static public class MyRunnable implements Runnable {
          public void run() {
                  settemp(template);
              }
  
          }
      }
  
      public static String gettemp() {
          return template;
      }
      public static void settemp(String template) {
          Recognition.template = template;
      }
  
  }
  </code></pre>
  
  <p>here i will not use AsynTask because i have some other issue that is reason i choose Thread even now the problem is Thread wait do any give the suggestion for this</p>