title: Java parallel stream use or not to use
body: <p><em>Is using of parallel stream insdead of executor services in Java considered as bad practice? Why?</em></p>
  
  <p>As you know <code>myList.parallelStream().map(e -&gt; ...)</code> will use <code>ForkJoinPool.common()</code> under the hood. So if you will use at least two parallel streams at the same time you can face issues when:</p>
  
  <ol>
  <li><code>map</code> function is blocking. But there is <a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.ManagedBlocker.html" rel="nofollow noreferrer">ForkJoinPool.ManagedBlocker</a> as a rescue.</li>
  <li><code>map</code> function can be very CPU intensive which will cause other parallel streams to starve. <em>Is there any way to set priority among <code>RecursiveTask</code>s or between <code>ForkJoinPool</code>s?</em></li>
  </ol>
  
  <p>In other hand you can create as many <code>ForkJoinPool</code>s as you want. <code>new ForkJoinPool(4).submit(() -&gt; myList.parallelStream()...</code>. <em>Is it considered performance-wise to use multiple <code>ForkJoinPool</code>s at one JVM?</em> </p>
  
  <h2>Update</h2>
  
  <p>Use or not parallel stream = use or not ForkJoinPool, right? I found <a href="https://stackoverflow.com/questions/9276807/whats-the-advantage-of-a-java-5-threadpoolexecutor-over-a-java-7-forkjoinpool">this</a> and <a href="https://www.ibm.com/developerworks/java/library/j-jtp11137/index.html" rel="nofollow noreferrer">this</a> links pretty useful to asnwer the last question</p>