Question Regarding JEP 444: Virtual Threads and Use of ForkJoinPool

David Holmes david.holmes at
Wed Jun 14 00:13:11 UTC 2023


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.


> 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, 
> <>
> Java Queue Editor, InfoQ 
> <>
> Editor at 
> <>
> About Me 
> <>
> <>

More information about the loom-dev mailing list