<div dir="ltr">Yep! I understand nothing has been decided yet. I just saw <a href="https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md/">https://github.com/openjdk/loom/blob/fibers/loom-docs/CustomSchedulers.md/</a> so I built the JVM over the weekend and was experimenting with it since I think the library I maintain has a interesting use case for schedulers.<div><br></div><div>For timed operations ideally I would like the virtual thread to request the scheduler it wants to do a timed operation and the scheduler decides how to accomplish this. That may be too high level an interface to add since it looks like more libraries use `<span style="color:rgb(53,56,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14px">java.util.concurrent.locks.LockSupport</span>`<span style="color:rgb(53,56,51);font-family:"DejaVu Sans",Arial,Helvetica,sans-serif;font-size:14px">. </span>This is my first time looking at the implementation of some of these low level calls, but maybe it would be more realistic to allow a pluggable time source and interception of these parking utilities.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, Jun 22, 2025 at 12:10 PM Alan Bateman <<a href="mailto:alan.bateman@oracle.com">alan.bateman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 22/06/2025 18:07, Quinn Klassen wrote:<br>
> :<br>
><br>
> Experimenting with the custom schedules it seems like we now could <br>
> control how threads are scheduled and executed (amazing!), but we <br>
> still can't control the current time or how threads sleep. For example <br>
> if a thread with a custom scheduler calls `Thread.sleep` there is no <br>
> way for the scheduler to control when that will return, even if the <br>
> scheduler tries to unpark the thread the `for` loop in <br>
> `VirtualThread.sleepNanos` will keep parking it. In other <br>
> languages that support a custom scheduler for tasks like Python, <br>
> Javascript, Dotnet, Rust or Ruby this sort of behaviour is customizable.<br>
><br>
> Is there a way currently to customize this behaviour that I <br>
> have missed or would this be something the team would be open to <br>
> exploring in the future?<br>
<br>
Just to say that this project hasn't decided whether to expose anything <br>
on schedulers at this time. There is some basic support in the loom repo <br>
for experimenting and to get more insight into the topic - is that what <br>
you are experimenting with?<br>
<br>
Timed operations, e.g. timed-Object.wait, sleep, ... have to deal with <br>
spurious wakeup. Are you looking to advance the time and have these <br>
operations complete early? Or maybe are looking for all time sources to <br>
be pluggable? Or maybe you are looking for the scheduler to know that a <br>
virtual thread is doing a timed operation?<br>
<br>
-Alan<br>
</blockquote></div>