As written, virtual threads are eventually mapped to actual threads. Let's say there are 1 million virtual threads that are created. In a 8 core processor, I assume there will be 8 kernel threads. So, my questions are
- how 1 million virtual threads are mapped to 8 kernel threads? What is the algorithm behind this?
- Why blocking is cheap in the virtual threads? As I understood this is because it does not block Carrier (Kernel) thread. But kernel thread uses context switch, so why it is still cheap?
- Is the virtual thread a good fit for use cases where code needs to call native method ( public native String getSystemTime();)