title: How port WaitForMultipleObjects to Java?
body: <p>I have some code in C++ for Windows and I intend to port it to Java. But unfortunately it is not so easy as I thought. Could someone help me, please?</p>
  
  <p>Please, take a look at algorithm:</p>
  
  <pre><code>HANDLE hExitEvent;
  HANDLE hDataAvailabeEvent;
  
  while(true)
  {
    WaitForMultipleObjects();
    if (hExitEvent is set)
      break;
    if (hDataAvailabeEvent)
    {
      process chunk of data;
      if (all data processed)
        ResetEvent(hDataAvailabeEvent);
    }
  }
  </code></pre>
  
  <p>hDataAvailabeEvent can be set from different threads. If all data is processed, then event resets and at calling WaitForMultipleObjects thread will suspend until new data arrives or time for thread exit comes.</p>
  
  <p>I've already seen question <a href="https://stackoverflow.com/questions/788835/waitformultipleobjects-in-java">Waitformultipleobjects in Java</a> but it's not suitable for my situation because I can't process all new data in 1 cycle iteration and processing spreads over some iterations.</p>
  
  <p>Thanks in advance!</p>