Can jdk 21 virtual threads execute tasks concurrently?

198 views Asked by At

According to https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html#GUID-DC4306FC-D6C1-4BCC-AECE-48C32C1A8DAA

Like a platform thread, a virtual thread is also an instance of java.lang.Thread. However, a virtual thread isn't tied to a specific OS thread. A virtual thread still runs code on an OS thread. However, when code running in a virtual thread calls a blocking I/O operation, the Java runtime suspends the virtual thread until it can be resumed. The OS thread associated with the suspended virtual thread is now free to perform operations for other virtual threads.

Virtual threads are based on platform threads, there are multiple virtual threads in a thread, can I have two virtual threads in a thread perform a task at the same time?

Two virtual threads in a thread perform a task at the same time

0

There are 0 answers