Hacker News new | ask | show | jobs
by twoodfin 20 days ago
My recollection is that M:N ("green") threads were pulled out because in the absence of a runtime that can guarantee a thread is never blocked, you essentially have to reintroduce all the complexity of an OS scheduler without the benefits of OS-wide context.

"Project Loom" spent much of its time (AFAICT) figuring out how to make every Java system-level API non-blocking without breaking backward compatibility. The only one they didn't get to for the initial release was Java's "interesting" built-in `synchronized` object monitor construct.

bcantrill has strong opinions on M:N and have always been curious what he thinks about Loom.

1 comments

Exactly, didn't want to go into the details. I think a key point is that back in the green-thread days they were kinda early on trying to do it and "extra" native threads probably felt like makings things worse without benefit since single-core CPU's with little memory every extra "real" thread would cost.

The C# async system iirc has "blocking workers", ie extra threads that takes care of blocking syscalls, so you're limited by a queue of them "waiting" for their respective "async" workload to finish but the rest of the runtime can chug along concurrently, iirc Project Loom also adopted that, so you have M:N for most code but some extra theads to take care of legacy codepaths (that the Java ecosystem has rewritten a lot of things into pure Java helps since native code calling is probably fairly "obscure" these days).