title: best practice to make a loop faster - is Multithreading an option?
body: <p>I call a Api Service with an index in the URL; for example the last index is: 420.555. I do this:</p>
  
  <pre><code>for(int i =0; i &lt;= 420555;i++){
    url = new URl("https://someURL/"+ i);
    read the json with BufferedReader reader = new BufferedReader( new InputStreamReader( url.openStream(), "UTF-8" ) )) {
  
     create object from json
     save the result to my DB
  }
  </code></pre>
  
  <p>the performance is very bad. </p>
  
  <p>( sure, there are many entries to save in my DB but it needs over 6 hrs and crashed because memory full in the JAVA VM )</p>
  
  <p>Do you have any Idea, how can i do this faster ?</p>
  
  <p>If you need the full code, i can post it. but i think the for loop is the problem...</p>
  
  <p>My idea was, to use Multithreading, but i have never worked befor and i'm not sure if it's best practice for this case. </p>
  
  <p>When multithreading is best practice, can you give me an example for this case? </p>