Question Regarding JEP 444: Virtual Threads and Use of ForkJoinPool
David Holmes
david.holmes at oracle.com
Wed Jun 14 00:13:11 UTC 2023
Hi,
On 14/06/2023 9:50 am, Bazlur Rahman wrote:
> Hello,
>
> I was reading JEP 444, which discusses the implementation of Virtual
> Threads. I've observed that the JDK's virtual thread scheduler employs a
> work-stealing ForkJoinPool operating in FIFO mode, which is distinct
> from the common pool operating in LIFO mode.
>
> This has sparked my curiosity because ForkJoinPool, to my understanding,
> has not traditionally been designed to handle I/O-bound tasks. However,
> the design of virtual threads seems to be aimed precisely at addressing
> such tasks.
Yes and it is the virtual threads mechanism that handles the I/O-bound
tasks, not the underlying FJP. Where a regular thread in the FJP would
block on an I/O operation and become unavailable for further use, it is
the virtual thread that blocks, allowing the carrier thread in the FJP
to continue executing other virtual threads.
Cheers,
David
-----
> Therefore, I'm curious as to why Java has opted to use the ForkJoinPool
> for scheduling virtual threads. I would greatly appreciate it if you
> could shed some light on what makes this design choice effective in
> managing I/O-bound tasks, despite the ForkJoinPool's traditional usage
> patterns.
>
> Thank you for your time and consideration. I look forward to your
> insights on this subject.
> *Thank you,*
>
> *-*
> *A N M Bazlur Rahman*
>
> ---
> /"And say: 'My Lord, increase me in knowledge.'" - Quran 20:114./
>
> *Java Champion*
> *Software Engineer*
> JUG Leader, JUGBD.org
> <https://mailtrack.io/trace/link/331a3fc3a3fa6407b1c1a71207d689d0bc35baca?url=http%3A%2F%2FJUGBD.org&userId=2428395&signature=31820ea85face89b>
> Java Queue Editor, InfoQ
> <https://mailtrack.io/trace/link/4e67b5f2b63d9a192a80a28578b56f26ab3495b9?url=https%3A%2F%2Fwww.infoq.com%2Fprofile%2FA-N-M-Bazlur-Rahman%2F&userId=2428395&signature=0e89d13e753a8ce2>
> Editor at Foojay.io
> <https://mailtrack.io/trace/link/ae78bc70831add10a5229ae14321984a51f052eb?url=https%3A%2F%2Ffoojay.io%2Ftoday%2Fauthor%2Fbazlur-rahman%2F&userId=2428395&signature=8a905c0967fa07c1>
> About Me
> <https://mailtrack.io/trace/link/040f4646e384e62ba0900a14bc61657dbcec43b2?url=https%3A%2F%2Fbazlur.ca%2Fabout%2F&userId=2428395&signature=fc5823af331c641e>
> https://bazlur.ca/
> <https://mailtrack.io/trace/link/130dee54b46a76f0c11f910de05c700cdda0bb77?url=https%3A%2F%2Fbazlur.ca%2F&userId=2428395&signature=90ba6ea5871c4665>
More information about the loom-dev
mailing list