title: Java get correct method return value in parallel execution environment
body: <p>I have two methods which can execute in parallely in my java class. Imagine method a calls getList method by passing fileA and gets the String list returned by getList method and method b calls getList method by passing fileB and acquires the List returned by getList.(Those list would be the contents of appropriate file as passed by the caller)</p>
  
  <pre><code>public void a(){
  List&lt;String&gt; list = getList(fileA);
  
      for(String s: list){
         //Analyse list and do something here 
      }
  }
  
  public void b(){
      List&lt;String&gt; list = getList(fileB);
  
      for(String s: list){
         //Analyse list and do something here 
      }
  }
  
  public List&lt;Stirng&gt; getList(File file){
  
      //Read lines in the file in to an array list
  
      //Return List 
  }
  </code></pre>
  
  <p>In a parallel method execution scenario, as I think this can be fall in to a situation like follows,
  in a half way reading fileA by getList method b gets invoked and it tries to read fileB using the same getList method.</p>
  
  <p>I want to clarify that in a such scenario does JVM guarantees that we are getting correct results for the calls from method a and method b ?</p>
  
  <p>If not how can I handle such scenario ?</p>