title: Is it safe to use parallelstream() to populate a Map in Java 8
body: <p>I have a list of 1 million objects, and I need to populate that into a Map. Now, I want to reduce the time for populating this into a Map, and for this I am planning on using Java 8 parallelstream() like this:</p>
  
  <pre><code>List&lt;Person&gt; list = new LinkedList&lt;&gt;();
  Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
  list.parallelStream().forEach(person -&gt;{
      map.put(person.getName(), person.getAge());
  });
  </code></pre>
  
  <p>I want to ask is it safe to populate a Map like this through parallel threads. Isn't it possible to have concurrency issues, and some data may get lost in the Map ? </p>