JVMTI resume and suspend for virtual and carrier threads
Alan Bateman
Alan.Bateman at oracle.com
Mon Apr 3 16:45:37 UTC 2023
On 03/04/2023 17:24, Babneet B Singh wrote:
> I would like to request clarification on how JVMTI resume and suspend work for a virtual thread and its associated carrier thread.
> Virtual thread runs on a carrier thread. Both are separate Java
> objects. JVMTI functions can be invoked separately on them. What is
> the relationship between the state of a virtual and carrier thread
> when JVMTI suspend and resume functions are invoked on them?
They are separate Thread objects for JVM TI too,.
> jvmti->SuspendThread(virtualThread) // Will this also suspend the
> carrier thread?
No, just the virtual thread. Remember the carrier is "blocked" when a
virtual thread is mounted, it continues when the virtual thread
unmounts. Once you get that mental model then most of the suspend/resume
issues should be become straight forward to reason about.
> jvmti->SuspendThread(carrierThread) // Will this also suspend the
> virtual thread?
No, the carrier will self-suspend when the virtual mount unmounts.
> jvmti->ResumeThread(virtualThread) // Will this resume both virtual
> thread and its carrier thread?
No, just the virtual thread.
> jvmti->ResumeThread(carrierThread) // Will this just resume the
> carrier thread and virtual thread will stay suspended?
No, just the carrier.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230403/b1ce9e70/attachment.htm>
More information about the loom-dev
mailing list