title: Wait and notify in android
body: <p>I am handling a thread in my application, I am facing a problem with Thread wait function. I created and show my UI using <code>runOnUIThread()</code> , my main thraed was waiting for my UI thread to finish ,after thraed finishes i have do some process in Main thread , here the problem is that Main Process is  always in waiting state even my thread finishes it;s job I am using wait and <code>notify()</code> function for this</p>
  
  <pre><code>      public String LSVerification() {
  
          String t = null;
  
              t="Sample string";
              synchronized(this)
  
              {
              AndroidHTMLActivity.this.runOnUiThread(ShowDialog) ;//here i call my thread
  
              try {
                 this.wait();//here i waiting for my thread to finish it's job
  
              //here i do some process after my thread finish it's job
                //the problem is here main process always in wait state
  
  
                  } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
  
              }
            return t;        
          }
  
          private Runnable ShowDialog = new Runnable() {
              public void run() {
                  String t = null;
          synchronized(ShowDialog)
  
              {
              Recognition recg=new Recognition(Activity.this);
  
                  recg.show();
  
  
              this.notify();
              }
  
              }
          };
  </code></pre>