Experiencing an issue with ScheduledExecutorService alongside VT

Alan Bateman Alan.Bateman at oracle.com
Mon Jul 22 07:46:24 UTC 2024


On 22/07/2024 07:09, Yuval Lombard wrote:
> Hi Alan,
>
> Thanks for the clarifications!
> OK regarding the pooling of the VT, now I understand what robert meant 
> about the partial code example.
>
> The scheduler is created in this way:
> ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1)
> then as the code example shows after it is granted with a permit to 
> execute a task, it delegates it to the VT by starting it this way:
> Thread.ofVirtual().start(() -> { ... }

I read Robert's mail as a comment on the code fragment in your first 
mail. The finally block in that code fragment releases a permit 
unconditionally whereas I assume you only want to release if acquired in 
that thread.

My comment is about thread dump you attached. Look at threads #73, #77 
and #83 as examples. The stack traces suggests a SPTE using virtual 
threads as worker threads. It's nothing to do with the issue we are 
discussing here, just a comment that on a something surprising that you 
might want to look into.

> I upgrade the jdk to the latest EA and test it again, and get back to 
> you in any case with the relevant thread dumps.
>
Thanks. As I mentioned, I think this is related to preemption when 
cancelling a timer after Object.wait(millis). We may have to publish a 
new EA build.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240722/8df3d61e/attachment.htm>


More information about the loom-dev mailing list