loom ea based jdk18 feedback
Alan Bateman
Alan.Bateman at oracle.com
Fri Nov 19 11:04:02 UTC 2021
On 18/11/2021 21:13, Jon Ross wrote:
> :
> 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?
If you are doing your own implementation of blocking I/O outside of the
JDK then park/unpark should be sufficient. Unpark will queue the virtual
thread to the scheduler so it continues on one of its thread. If you
really want to restrict the scheduler to 1 thread then run with
-Djdk.defaultScheduler.maxPoolSize=1. You are in very advanced territory
if want fine control on the OS threads, this isn't a priority for this
project right now but we will come back to it.
-Alan
More information about the loom-dev
mailing list