Reputation: 1292
I'm experimenting with Java virtual threads and wonder if it's possible to run parallel Stream
s with virtual threads. By default, parallel streams are run on the common ForkJoinPool
, but one could use a custom thread pool by calling a Stream
's terminal operation on the worker thread of another ForkJoinPool
. But as of JDK 20, ForkJoinPool
can only manage threads of ForkJoinWorkerThread
instances.
Is there a VirtualThread
equivalent for ForkJoinWorkerThread
? Or is there an alternative way to run tasks in a work-stealing manner using virtual threads?
Upvotes: 5
Views: 1259