title: Is this a bug in Files.lines(), or am I misunderstanding something about parallel streams?
body: <p>Environment: Ubuntu x86_64 (14.10), Oracle JDK 1.8u25</p>
  
  <p>I try and use a parallel stream of <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#lines-java.nio.file.Path-java.nio.charset.Charset-" rel="nofollow noreferrer"><code>Files.lines()</code></a> but I want to <a href="http://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#skip-long-" rel="nofollow noreferrer"><code>.skip()</code></a> the first line (it's a CSV file with a header). Therefore I try and do this:</p>
  
  <pre><code>try (
      final Stream&lt;String&gt; stream = Files.lines(thePath, StandardCharsets.UTF_8)
          .skip(1L).parallel();
  ) {
      // etc
  }
  </code></pre>
  
  <p>But then one column failed to parse to an int...</p>
  
  <p>So I tried some simple code. The file is question is dead simple:</p>
  
  <pre><code>$ cat info.csv 
  startDate;treeDepth;nrMatchers;nrLines;nrChars;nrCodePoints;nrNodes
  1422758875023;34;54;151;4375;4375;27486
  $
  </code></pre>
  
  <p>And the code is equally simple:</p>
  
  <pre><code>public static void main(final String... args)
  {
      final Path path = Paths.get("/home/fge/tmp/dd/info.csv");
      Files.lines(path, StandardCharsets.UTF_8).skip(1L).parallel()
          .forEach(System.out::println);
  }
  </code></pre>
  
  <p>And I <em>systematically</em> get the following result (OK, I have only run it something around 20 times):</p>
  
  <pre><code>startDate;treeDepth;nrMatchers;nrLines;nrChars;nrCodePoints;nrNodes
  </code></pre>
  
  <p>What am I missing here?</p>
  
  <hr>
  
  <p><strong>EDIT</strong> It seems like the problem, or misunderstanding, is much more rooted than that (the two examples below were cooked up by a fellow on FreeNode's ##java):</p>
  
  <pre><code>public static void main(final String... args)
  {
      new BufferedReader(new StringReader("Hello\nWorld")).lines()
          .skip(1L).parallel()
          .forEach(System.out::println);
  
      final Iterator&lt;String&gt; iter
          = Arrays.asList("Hello", "World").iterator();
      final Spliterator&lt;String&gt; spliterator
          = Spliterators.spliteratorUnknownSize(iter, Spliterator.ORDERED);
      final Stream&lt;String&gt; s
          = StreamSupport.stream(spliterator, true);
  
      s.skip(1L).forEach(System.out::println);
  }
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>Hello
  Hello
  </code></pre>
  
  <p>Uh.</p>
  
  <p>@Holger suggested that this happens for any stream which is <code>ORDERED</code> and not <code>SIZED</code> with this other sample:</p>
  
  <pre><code>Stream.of("Hello", "World")
      .filter(x -&gt; true)
      .parallel()
      .skip(1L)
      .forEach(System.out::println);
  </code></pre>
  
  <p>Also, it stems from all the discussion which already took place that the problem (if it is one?) is with <code>.forEach()</code> (as <a href="https://stackoverflow.com/questions/28259636/is-this-a-bug-in-files-lines-or-am-i-misunderstanding-something-about-paralle#comment44876969_28259636">@SotiriosDelimanolis first pointed out</a>).</p>