title: Work two methods in seperate threads simultaneously
body: <p>I am trying to run two methods in parallel. To do that I have written a code like below:</p>
  
  <p>After getting critiques, I thought I should be clearer. <code>method1()</code> is a local method which runs on my local computer. <code>method2()</code> is a web method which sends some data to a remote computer to process and return result. Since the work takes too long I divide the data into 2 pieces and one part is processed on local and the other one is on remote.</p>
  
  <p>After the jobs finishes I combine the results.</p>
  
  <pre><code>//str1 and str2 are defined outside the main method.
  
  Thread[] threads = new Thread[2];
  
  threads[0] = new Thread() {
      @Override
      public void run() { str1 = method1(); }
  };
  
  
  threads[1] = new Thread() {
      @Override
      public void run() { str2 = method2(); }
  };
  
      threads[0].start();
      threads[1].start();
  </code></pre>
  
  <p>I get null from <code>method2()</code> in return when I try this way. Bu if I run <code>method2()</code> outside thread definition str2 is <code>null</code>.</p>
  
  <pre><code>Thread thread = new Thread() {
      @Override
      public void run() { str1 = method1(); }
  };
  
  thread.start();
  
  str2 = method2();  
  </code></pre>
  
  <p><code>method2()</code> returns what it should return. The explanation could be that <code>thread[1].start()</code> does not start.</p>