title: Muti thread join & get return values
body: <p>I'm trying to do multiple heavy calculations using threads.
  Then I need to do something with the results after making sure all threads have finished its job.</p>
  
  <p>Here's the basic code:</p>
  
  <pre><code>    private class Runner implements Runnable {
        private String _result = "fail";
  
        public String get_results() {
          return _result;
        }
  
        public void run() {
          _result = "do complex calculation";
        }
     }
  
     public void test() {
          List&lt;Thread&gt; threads = new ArrayList&lt;Thread&gt;();
          List&lt;Runner&gt; threadObjects = new ArrayList&lt;Runner&gt;();
  
          for (int i = 0; i &lt; 10; i++) {
              Runner runner = new Runner();
              Thread t = new Thread(runner);
              t.start();
              threads.add(t);
              threadObjects.add(runner);                
          }
  
          for (Thread thread : threads) {
              try {
                  thread.join();
              } catch (InterruptedException ex) {
              }
          }
  
          for (Runner threadObject : threadObjects) {
              System.out.println(threadObject.get_results());
          }
  
     }    
  </code></pre>
  
  <p>My question is, is above snippet a common or a good approach to get calculation value?
  If not please suggest a better ones.
  Also sometimes I got runner.get_results() reponse = "fail", it seems calculation does not processed at all.</p>
  
  <p>Thanks</p>