loom ea based jdk18 feedback

Jon Ross jonross at gmail.com
Thu Nov 18 21:13:12 UTC 2021


On Thu, Nov 18, 2021 at 11:28 AM Alan Bateman <Alan.Bateman at oracle.com> wrote:
>
> On 18/11/2021 17:51, Jon Ross wrote:
> > :
> This thread has got a bit confusing. Ron's message was about not
> exposing a way to use a custom scheduler in the first release. It sounds
> like you are asking about changing a library that does blocking I/O
> operations outside of the JDK to play nicely with virtual threads so
> they release the underlying thread to do other work. Is that right? If
> so, then the primitives you are looking for are LockSupport.park and unpark.
>

Thank you Alen for the disambiguation. I apologize if I muddled things up.

I will need to experiment a bit, but park/unpark does look like what I
am looking for, but I think I might need the custom scheduler as well.

For virtual threads, when you unpark, what determines which OS thread
will the virtual thread be run on? The Executor in sope? Something
else?

The pathological case is a single-OS-threaded app that only wants to
use the main() OS thread. Does unpark of virtual thread work in this
case? Does it run the unpark'd code on the thread that  called
unpark() and unpark returns when the virtual thread is parked again?
Or are they running in parallel w/ the JVM task "switching" on a
single OS thread? or other? Is it possible to have os-thread control
w/o the custom scheduler?

-Jon


More information about the loom-dev mailing list