r/java • • Apr 06 '22

JEP 425: Virtual Threads (Preview)

https://openjdk.java.net/jeps/425
175 Upvotes

50 comments sorted by

View all comments

4

u/python_geek Apr 06 '22

To take advantage of virtual threads, it is not necessary to rewrite your program. Virtual threads do not require or expect application code to explicitly hand back control to the scheduler; in other words, virtual threads are not cooperative

The JEP says this is not cooperative multi-tasking. But when you make a blocking I/O call, surely the underlying scheduling will "yield" to a different OS thread? Isn't that cooperative multi-tasking?

Surely I am confusing something here...

4

u/vips7L Apr 07 '22

When the underlying runtime does the yield, it's preemptive multi-tasking.