title: How to wait in NSThread until some event occur in iOS?
body: <p>How to wait inside the NSThread until some event occur in iOS?</p>
  
  <p>eg, We created a NSThread and started a thread loop. Inside the thread loop, there is condition to check whether the  message queue has any messages. If there is a message, then it will call the corresponding method to do some operation, else it should wait until the message queue gets populated with a new message.</p>
  
  <p>Is there any API or methods available to wait until some event occur?</p>
  
  <pre><code>For Example 
  
  NSThread *thread = [NSThread alloc]....@selector(threadLoop)
  
  - (void)threadLoop
  {
     // Expecting some API or method that wait until some messages pushed into the message queue
     if (...) {
  
     }
  }
  </code></pre>
  
  <p>Any help should be appreciated.</p>