Virtual threads vs JMM + public API for replacing scheduler

Ron Pressler ron.pressler at oracle.com
Tue Nov 22 12:11:15 UTC 2022


Hi.

> On 22 Nov 2022, at 09:37, Krzysztof Ślusarski <pasqal at gmail.com> wrote:
> 
> Hi, currently in performance world you can see a lot of investment in
> thread-per-core architecture. I tried to use loom virtual threads to
> create a POC with such a design, and I see two missing parts:
> - I cannot find any information about how virtual threads are
> connected with Java Memory Model. If I have multiple virtual threads
> that are running on the same carrier thread, can I treat it as
> single-threaded execution in terms of JMM?

The notions of a virtual thread scheduler as well as that of a “carrier” thread are not currently part of the specification, so the behaviour of non-specified components is not specified. As things stand, the JMM guarantees for two threads are unchanged regardless of their implementation. If and when mechanisms for the control of virtual threads scheduling are added, their behaviour will be specified accordingly.

> - There is no public API for switching the scheduler (I believe there
> was one in the past), can we ask for bringing it back?

That’s correct, but the feature isn't ready for release. While it’s certainly something we’re considering, if you have experiments you can share that would demonstrate its utility they could help us guide the design of such a feature.


— Ron


More information about the loom-dev mailing list