title: How to use multi-threading to parallellize a for loop in Java?
body: <p>I am writing a code which picks the multiple API call details from a file and executes those ones by one and provides the response data in an ArrayList. Below is my current code.</p>
  
  <pre><code>ArrayList&lt;APICallDetails&gt; apiCallDetailsArray = new ArrayList&lt;&gt;();
  APICallDetails apiCallDetails = new APICallDetails();
  for (count= 1; count &lt;= callsCount; count++){
          try{
              apiCallDetails = new APICallDetails();
              apiCallDetails.setName(property.getPropertyReader(callName+"_"+count+"_Name", propsFile));
              apiCallDetails.setHost(marketConfigs.getRawJson().get(property.getPropertyReader(callName+"_"+count+"_Host", propsFile)).toString().replaceAll("\"", ""));
              apiCallDetails.setPath(property.getPropertyReader(callName+"_"+count+"_Path", propsFile));
              apiCallDetails.setMethod(property.getPropertyReader(callName+"_"+count+"_Method", propsFile));
              apiCallDetails.setBody(property.getPropertyReader(callName+"_"+count+"_Body", propsFile));
  
              apiCallDetails = sendAPIRequest.mwRequestWithoutBody(apiCallDetails, marketConfigs);
              BufferedWriter out = null;
              try {
                  out = new BufferedWriter ( new FileWriter ( "C:\\file"+count+".html"));
                      out.write("something");
                      out.close();
                  } catch (IOException e) {
                      e.printStackTrace();
                      logger.error(new Date()+" - Error in "+getClass()+".apiCallRequester() flow: "+e.toString());
                  }
  
              apiCallDetailsArray.add(apiCallDetails);
  
          }catch(NullPointerException e){
              e.printStackTrace();
              logger.error(new Date()+" - Error in "+getClass()+".apiCallRequester() flow: "+e.toString());
          }
      }
  </code></pre>
  
  <p>As there are more API calls, this is taking the sum of the response time of all the calls. I want these calls to run parallelly and store the response data in an ArrayList which I can use further. 
  I am new to Java so, can someone please help me with this?</p>