Controlling the VirtualThread.scheduler

Peter Veentjer alarmnummer at gmail.com
Tue Jun 7 05:09:43 UTC 2022


Is it possible to configure the Scheduler in the VirtualThread?

I'm working on a thread per core design. Each CPU runs a (pinned) platform
thread called the EventloopThread which runs the actual eventloop. And all
VirtualThread created in the EventloopThread should be tied to their owning
EventloopThread.  They should never be allowed to run on any other thread.

The constructor of the VirtualThread does allow for a scheduler to be
passed, but it is private and on initial inspection, it seems there is no
proper entrance to configure the scheduler. Either a null scheduler is
passed or some 'test' instance. So as a consequence, it seems that
VirtualThreads are always executed on an ForkJoinPool and hence can run on
any Thread.

Regards,

Peter.


More information about the loom-dev mailing list