Custom Schedulers: Customize current time and timed waits

Alan Bateman alan.bateman at oracle.com
Sun Jun 22 19:10:41 UTC 2025



On 22/06/2025 18:07, Quinn Klassen wrote:
> :
>
> Experimenting with the custom schedules it seems like we now could 
> control how threads are scheduled and executed (amazing!), but we 
> still can't control the current time or how threads sleep. For example 
> if a thread with a custom scheduler calls `Thread.sleep` there is no 
> way for the scheduler to control when that will return, even if the 
> scheduler tries to unpark the thread the `for` loop in 
> `VirtualThread.sleepNanos` will keep parking it. In other 
> languages that support a custom scheduler for tasks like Python, 
> Javascript, Dotnet, Rust or Ruby this sort of behaviour is customizable.
>
> Is there a way currently to customize this behaviour that I 
> have missed or would this be something the team would be open to 
> exploring in the future?

Just to say that this project hasn't decided whether to expose anything 
on schedulers at this time. There is some basic support in the loom repo 
for experimenting and to get more insight into the topic - is that what 
you are experimenting with?

Timed operations, e.g. timed-Object.wait, sleep, ... have to deal with 
spurious wakeup. Are you looking to advance the time and have these 
operations complete early? Or maybe are looking for all time sources to 
be pluggable? Or maybe you are looking for the scheduler to know that a 
virtual thread is doing a timed operation?

-Alan


More information about the loom-dev mailing list