title: How most effective add some info to list with multiple threads in Java?
body: <p>I have some task to aggregate some info from multiple links in most effective way, using multithreading. The links are at some array. By now, i have something like this solution:</p>
  
  <pre><code>Arrays.stream(link).parallel().forEach(link -&gt; {
          try {
              String result = doSomeJobWithLink(link);
              System.out.println(result);
          } catch (IOException e) {
              e.printStackTrace();
          }
      });
  </code></pre>
  
  <p>And it works pretty good (job has done for 2 secs).</p>
  
  <p>But I wanna not to print result in my try block, but collect results in some list (or other collection), so i did it this way:</p>
  
  <pre><code>List&lt;String&gt; resultList = Collections.synchronizedList(new ArrayList&lt;&gt;());
  Arrays.stream(link).parallel().forEach(link -&gt; {
          try {
              String result = doSomeJobWithLink(link);
              resultList.add(result);
          } catch (IOException e) {
              e.printStackTrace();
          }
      });
  resultList.forEach(System.out::println);
  </code></pre>
  
  <p>But it's took about 5-8 sec's instead of two. Can I speed it up someway?</p>