Experiencing an issue with ScheduledExecutorService alongside VT

Yuval Lombard yuval.l at securithings.com
Mon Jul 22 06:09:14 UTC 2024


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 upgrade the jdk to the latest EA and test it again, and get back to you
in any case with the relevant thread dumps.

On Sun, 21 Jul 2024 at 22:56, Alan Bateman <Alan.Bateman at oracle.com> wrote:

>
>
> On 21/07/2024 19:14, Yuval Lombard wrote:
> > Hi Alan,
> >
> > By "So I
> > think you are running into a bug.." do you mean on my end? (Hope you
> > do 😅)
>
> I should have been clearer, I meant this is likely a JDK bug in the EA
> build. From the thread I'm 80% certain it's related preemption when
> cancelling the timer after Object.wait(millis).
>
> The only thing that you might want to check is whether something is
> accidentally pooling virtual threads to execute periodic tasks, meaning
> something is calling Executors.newScheduleThreadPool with a thread
> factory that creates virtual threads. It's not the cause of this hang,
> just something that I see in the thread dump.
>
> >
> > When scheduling my tasks with platform threads I dont see it is being
> > reproduced, although I must say my current platform threads scheduler
> > is different (quartz scheduler) and does not make use of semaphores
> > (but instead it pools its workers) that is why I suspect my usage of
> > semaphores with VT.
> >
> > Also when I try to execute the vthread_summary command you suggested I
> > get this error:
> > java.lang.IllegalArgumentException: Unknown diagnostic command
> Ah right, this jcmd is not in the older EA build so it can't be used
> until you pick up a more recent EA build.
>
> -Alan
>


-- 

Kind regards,

*Yuval Lombard*

*Lead Software Engineer*

+972.50.548.0111

yuval.l at securithings.com

[image: logo_black.png]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240722/53dddf0f/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_black.png
Type: image/png
Size: 99833 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20240722/53dddf0f/logo_black-0001.png>


More information about the loom-dev mailing list