Warren Nocos
Warren Nocos

Reputation: 1292

Parallel Stream with Virtual Threads: Java VirtualThread equivalent for ForkJoinWorkerThread

I'm experimenting with Java virtual threads and wonder if it's possible to run parallel Streams 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

Answers (0)

Related Questions