title: Why does the parallel stream not use all the threads of the ForkJoinPool?
body: <p>So I know that if you use the <code>parallelStream</code> without a custom ForkJoinPool it will use the default ForkJoinPool which by default has one less threads as you have processors.</p>
  
  <p>So, as <a href="https://stackoverflow.com/a/22269778/3645944">stated here</a> (and also in the other answer of that question) in order to have more parallelism, you have to:</p>
  
  <blockquote>
    <p>submit the parallel stream execution to your own ForkJoinPool: yourFJP.submit(() -> stream.parallel().forEach(doSomething));</p>
  </blockquote>
  
  <p>So, I did this:</p>
  
  <pre><code>import java.util.Set;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.ForkJoinPool;
  import java.util.stream.IntStream;
  import com.google.common.collect.Sets;
  
  public class Main {
  
      public static void main(String[] args) throws InterruptedException, ExecutionException {
  
          ForkJoinPool forkJoinPool = new ForkJoinPool(1000);
  
          IntStream stream = IntStream.range(0, 999999);
  
          final Set&lt;String&gt; thNames = Collections.synchronizedSet(new HashSet&lt;String&gt;());
  
          forkJoinPool.submit(() -&gt; {
              stream.parallel().forEach(n -&gt; {
  
                  System.out.println("Processing n: " + n);
                  try {
                      Thread.sleep(500);
                      thNames.add(Thread.currentThread().getName());
                      System.out.println("Size: " + thNames.size() + " activeCount: " + forkJoinPool.getActiveThreadCount());
                  } catch (Exception e) {
                      throw new RuntimeException(e);
                  }
              });
          }).get();
      }
  }
  </code></pre>
  
  <p>I made a Set of thread Names in order to see how many threads are being created, and also logged the number of active threads that the pool has and both numbers don't grow up more that 16, so that means that the parallelism here is not being more than 16 (why even 16?). If I do not use the forkJoinPool, I get 4 as parallelism, which is according to the number of processors I have.</p>
  
  <p>Why does it give me 16 and not 1000?</p>