title: Why don't parallel Streams run as fast with Virtual Threads as the common thread pool?
body: <p>I am experimenting with Virtual Threads in my <a href="https://github.com/kolotyluk/loom-lab" rel="nofollow noreferrer">loom-lab</a> project, and wanted to see if Virtual Threads are faster than Platform Threads when doing a parallel stream, but it actually seems slower.</p>
  <pre><code>try (var executorService = Executors.newThreadPerTaskExecutor(virtualThreadFactory)) {
      var candidates3 = LongStream.iterate(3, x -&gt; x &lt; count, x -&gt; x + 2);
      time4 = System.currentTimeMillis();
      var primes3 = executorService.submit(() -&gt;
          candidates3.parallel()
              .filter(candidate -&gt; isPrime(candidate)).toArray()
      ).get();
      time5 = System.currentTimeMillis();
  }
  </code></pre>
  <p>where ultimately I get the output (in milliseconds)</p>
  <pre><code>sequential time = 7546
  parallel   time = 1289
  virtual    time = 1388
  </code></pre>
  <p>and in general using Virtual Threads is slower than the common ForkJoinPool. Am I making some basic mistake or misunderstanding somewhere, or has Project Loom not been integrated with Java Streams yet?</p>