title: Concurrency issues with parallel()
body: <p>I have a problem, where this code does not return the same value each time it is run. I assume it is because it is not threadsafe and I am having some concurrency issues with parallel(). I have tried to use a spliterator, and that works, but runtime because 3 times worse, the same as sequental. How else can I do this ?</p>
  
  <p>Ps:
  traverseDirectory returns a BlockingQueue of all .txt files in a directory.</p>
  
  <pre><code>try {
      pq = traverseDirectory(dir, pq);
  
      while(!pq.isEmpty()){
  
          File f = pq.take();
          LineNumberReader lr = new LineNumberReader(new FileReader(f));
          lr.lines()
              .parallel()
              .forEach((line) -&gt; {
                  String[] words = line.split("\\s+");
                  for( String word : words ){
                      wordList.add(word);
                  }
  
               }); // foreach
  
       } // while
  
  } //try
  catch (IOException | InterruptedException e) {}
  
  System.out.println("size: " + wordList.size());
  </code></pre>
  
  <p><em>EDIT</em>
  I forgot to mention, that I need to keep track of in which line the word has been found!</p>