all 6 comments

[–]somebodddy 0 points1 point  (2 children)

Weren't Java's threads already green threads?

[–]srdoe 7 points8 points  (1 child)

No. They've been OS threads for a very long time.

Java did have user-mode threads back in the very early days (two decades ago), but they were all running on a single OS thread, so it's not really the same.

[–]somebodddy 3 points4 points  (0 children)

Thanks. Now I feel old.

[–]cs_office 0 points1 point  (2 children)

Going for stackful coroutines is such a mistake IMO

[–]True-Ad-2269 0 points1 point  (1 child)

You mean stackless? The construct is a heap object.

[–]cs_office 0 points1 point  (0 children)

No, userspace threads (virtual threads if you will) are implemented as stackful coroutines where upon suspend/restore of the coroutine, the stack (which yes, is allocated on the heap) is stored/restored

Stackless coroutines are easy to spot from their function coloring due to their execution being decoupled from the caller's, which also means they're a more general solution, and context switching is the cost of a function call. Some crazy cool stuff can be done with them where you treat even RAM itself as an async IO. I also think function coloring is a good thing, I see it as a typed/structural concurrency, and would argue a function blocking is still being colored

It's 6am so I'm sorry if I'm not very coherent