title: GWT synchronization
body: <p>i'm doing a function in gwt<br>
  it sends an IQ stanza into a server and has to wait for the server answer<br>
  in the function i make the handler that waits for the answer from the server to that IQ stanza  </p>
  
  <p>so what i need is for the function to wait until i get the response from the server and after that do other stuff<br>
  i'm a beginner in gwt so any thoughts would be great<br>
  thanks</p>
  
  <pre><code>public void getServices()
      {
          IQ iq = new IQ(IQ.Type.get);
          iq.setAttribute("to", session.getDomainName());
          iq.addChild("query", "http://jabber.org/protocol/disco#items");
  
          session.addResponseHandler(iq, new ResponseHandler() 
          {
              public void onError(IQ iq, ErrorType errorType, ErrorCondition errorCondition, String text) 
              {
                  &lt;do stuff&gt;
              }
              public void onResult(IQ iq) 
              {
                  &lt;do stuff&gt;
              }
          });
  
          session.send(iq);
  
          &lt;after receiving answer do stuff&gt;   
      }
  </code></pre>