1

As I understand, a virtual thread is actually a "task", not a thread. A virtual thread is executed by carrier threads inside a ForkJoinPool. When a virtual thread encounters blocking I/O and goes into a waiting state, it stops its work and saves its stack frame to the heap. The carrier thread that was actually executing the task is now free to handle other tasks. This action is called "unmount". When the blocking I/O is complete, the virtual thread that was unmounted will wait in the queue of the carrier thread with its stack frame stored in the heap to resume work, and when it is its turn, work will resume. This action is called "mount".

I'm wondering how the completion of the blocking operation can be detected when there is no thread actually waiting for it.

ParkCheolu
  • 1,175
  • 2
  • 14
  • 30
  • A code example would improve your question. – tgdavies Jul 14 '23 at 07:22
  • 2
    Does this https://stackoverflow.com/questions/70174468/project-loom-what-happens-when-virtual-thread-makes-a-blocking-system-call answer your question? How it does it depends on the OS and JVM implementation. – M. Deinum Jul 14 '23 at 07:31
  • @M.Deinum ah, thank you. The link actually answers exactly what I asked. I'll close the question. – ParkCheolu Jul 14 '23 at 07:39

0 Answers0