title: Return values from Java Threads
body: <p>I have a Java Thread like the following:</p>
  
  <pre><code>   public class MyThread extends Thread {
          MyService service;
          String id;
          public MyThread(String id) {
              this.id = node;
          }
          public void run() {
              User user = service.getUser(id)
          }
      }
  </code></pre>
  
  <p>I have about 300 ids, and every couple of seconds - I fire up threads to make a call for each of the id. Eg.</p>
  
  <pre><code>for(String id: ids) {
      MyThread thread = new MyThread(id);
      thread.start();
  }
  </code></pre>
  
  <p>Now, I would like to collect the results from each threads, and do a batch insert to the database, instead of making 300 database inserts every 2 seconds.</p>
  
  <p>Any idea how I can accomplish this?</p>