Trying to understand internals of Java virtual threads

Siddharth Jain siddhsql at gmail.com
Fri Sep 1 17:25:23 UTC 2023


Thanks all. I like the guy in the youtube. his videos are really good.

On Fri, Sep 1, 2023 at 9:36 AM Pedro Lamarão <pedro.lamarao at prodist.com.br>
wrote:

> Em sex., 1 de set. de 2023 às 13:08, Siddharth Jain <siddhsql at gmail.com>
> escreveu:
>
>
>> I just have a simple question re: java virtual threads which is how does
>> the virtual thread know when its time to yield to another thread? as
>> example say i am running code using the synchronous pg JDBC driver inside a
>> vthread. there is nothing in the pg JDBC driver per se that tells a vthread
>> to yield when its waiting for response back from the database. in fact the
>> driver is not even aware of any vthread. is the yield logic something
>> managed at the JVM layer? how? any details would be appreciated. thanks,
>>
>
> This is generally the same for virtual threads in the JVM and platform
> threads in the operating system.
> Threads don`t block or unblock themselves; the system blocks and unblocks
> threads as appropriate.
> When a platform thread calls into the system for I/O, it is the I/O
> subsystem that causes the thread to block (waiting for I/O) and to unblock
> (when I/O has completed).
>
> --
> Pedro Lamarão
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230901/17b039e3/attachment.htm>


More information about the loom-dev mailing list