title: Parallel Stream is taking much time than stream in java
body: <p>I was learning java stream api and I found this issue in code.</p>
  <p><strong>Here is my code</strong></p>
  <pre><code> long s = System.currentTimeMillis();
   IntStream.range(1, 10).parallel().forEach( x -&gt;{
        System.out.println( &quot;Thread -&gt; &quot;+ Thread.currentThread().getName() +&quot; &quot;+ x );
   });
   long e = System.currentTimeMillis();
   System.out.println(&quot;Time taken &quot;+ (e-s) + &quot; ms&quot;);
  
   System.out.println(&quot;---------------------&quot;);
  
   s = System.currentTimeMillis();
   IntStream.range(1, 10).forEach( x -&gt;{
       System.out.println( &quot;Thread -&gt; &quot;+ Thread.currentThread().getName() +&quot; &quot;+ x );
   });
   e = System.currentTimeMillis();
   System.out.println(&quot;Time taken &quot;+ (e-s) + &quot; ms&quot;);
  </code></pre>
  <p><strong>Here is the output</strong></p>
  <pre><code>Thread -&gt; main 6
  Thread -&gt; ForkJoinPool.commonPool-worker-7 2
  Thread -&gt; ForkJoinPool.commonPool-worker-7 5
  Thread -&gt; ForkJoinPool.commonPool-worker-13 1
  Thread -&gt; ForkJoinPool.commonPool-worker-11 4
  Thread -&gt; ForkJoinPool.commonPool-worker-3 3
  Thread -&gt; ForkJoinPool.commonPool-worker-15 9
  Thread -&gt; ForkJoinPool.commonPool-worker-9 7
  Thread -&gt; ForkJoinPool.commonPool-worker-5 8
  Time taken using parallel stream 29 ms
  -------------------------------------
  Thread -&gt; main 1
  Thread -&gt; main 2
  Thread -&gt; main 3
  Thread -&gt; main 4
  Thread -&gt; main 5
  Thread -&gt; main 6
  Thread -&gt; main 7
  Thread -&gt; main 8
  Thread -&gt; main 9
  Time taken simple stream 1 ms
  </code></pre>
  <p>I have tried this code on sts and inteliJ IDE, results are same. Parallel is taking longer time than sequential.
  Is there a problem with my jdk? please suggest.</p>