The introduction of virtual threads in Java 21 has created a lot of buzz around the community. While I still try to wrap my head around actual benefit I will be getting by this feature, I stumble upto three terminologies
- virtual thread
- carrier thread
- platform thread
While I understood that the platform thread is an actual OS thread and the virtual thread Virtual threads are a lightweight implementation of threads that is provided by the JDK rather than the OS, and somehow these two threads are tied via a carrier thread. But I am still unclear about their exact anotomy and how they work in conjection
I assume that you are referring to the terminology in the Oracle documentation for Virtual Threads. This document says this:
Further on, the document does use the term "carrier thread" rather than just "carrier".
What the document is saying is that some of the time a virtual thread is assigned to a platform thread. While it is assigned, the platform thread is the carrier (or carrier thread) for the virtual thread.
That is not correct. The carrier thread is actually a platform thread. It is just called a carrier thread because its purpose is to "carry" a virtual thread. There are really just two threads here, not three.