title: Wait for multiple events in one thread on Java
body: <p>I'm new to multi threading, and am working on an assignment regarding this topic.</p>
  
  <p>I have a thread, that sends events to another thread, according to a timed schedule. Sending the event returns me a pseudo-future object (one I had to implement myself). Upon resolving the <code>Future</code> object, I should take an action. However, I mustn't wait for it, as I have to wake up on time and send every event on time. The order of completion of the events is also unknown.</p>
  
  <p>What can I do to react to every <code>Future</code> response on time, AND send events on time (according to the schedule)?</p>
  
  <p>Thanks.</p>
  
  <p>Partial implementation of future:</p>
  
  <pre><code>public class Future&lt;T&gt; {
  
  private T result;
  boolean IsDone;
  
  /**
   * This should be the the only public constructor in this class.
   */
  public Future();
  
  public T get();
  public T get(long timeout, TimeUnit unit);
  
  public void resolve (T result) {
      this.result=result;
      IsDone=true;
  }
  
  /**
   * @return true if this object has been resolved, false otherwise
   */
  public boolean isDone() {
      return IsDone;
  }
  </code></pre>