title: Java - Handling Non-Blocking Calls
body: <p>In my application I am using a third-party API. It is a non-blocking method which returns immediately. I have a collection of elements over which I have to invoke this method.</p>
  
  <p>Now, my problem is that I have to find a way till all the method execution gets completed and do my next operation. How can I handle this? I cannot modify the third-party API.</p>
  
  <p>In short it looks like this</p>
  
  <pre><code>for(Object object: objects){
   methodA(object); //this is a non-blocking call and returns immediately
  }
  // here I want to do my next task only after all the methodA calls completed execution
  </code></pre>