title: Waiting for Event
body: <p>I need to know how to wait for event to be triggered to set a Boolean. I got 2 classes simple classes: MainClass and Wait class:</p>
  
  <pre><code>    MainClass()
      {
  
          WebView wv; //It's already initialized from the xml and linked in the original code
          Wait waiting = new Wait();
          if(waiting(wv,URL))
          {
              wv.loadURL("javascript: ....");
          }
  
      }
  
      public Class Wait()
      {
          Boolean pageLoaded = false;
          Wait waiting = this;
          public boolean waitForPage(wv,URL)
          {
  
              wv.setWebViewClient(new WebViewClient()
              {
  
                  public void onPageFinished(WebView webView, String url )
                  {
                      pageLoaded = true;
                      synchronized(waiting)
                      this.nothifyAll();
  
                  }
  
              });
  
              wv.loadURL(URL);
  
              synchronized(this)  // --&gt; End up in an Endless Loop
                  this.wait();
  
              if(pageLoaded)
                  return true;
  
              return false;
          }
      }
  </code></pre>
  
  <p>Does anybody know why it doesn't get synchronized and finally end up in an endless Loop? Maybe I use the wrong eventhandler?
  The <code>this.wait();</code> seems to be like an <code>While(true)</code> verifying on a Boolean set by <code>NoifyAll()</code>. Please some Idea, how I can wait for these Events and Hold the program flow until the event is fired!</p>