<div dir="ltr"><div dir="ltr">Em sex., 1 de set. de 2023 às 13:08, Siddharth Jain <<a href="mailto:siddhsql@gmail.com">siddhsql@gmail.com</a>> escreveu:<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>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, </div></div></blockquote></div><div><br></div><div>This is generally the same for virtual threads in the JVM and platform threads in the operating system.</div><div>Threads don`t block or unblock themselves; the system blocks and unblocks threads as appropriate.</div><div>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).</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Pedro Lamarão</div></div></div></div>