Re:Networking I/O with Virtual Threads – Under the hood
by DaiPlusPlus on Thursday July 08, 2021 @06:17PM
(#27778295)
java.nio.channels was introduced in Java SE 7, not 1.4. It also is far from a drop-in replacement for InputStream/OutputStream.
Even with Loom's green-threads (not the original green-threads) async IO in Java will be too otherworldly until Java's language designers cease their intrasigence about adding first-class support for `await`.
Re:Networking I/O with Virtual Threads – Under the hood
by native_samples on Friday July 09, 2021 @04:43AM
(#27781658)
I don't see how you arrived at that conclusion at all. Async/await is always strictly harder to use than green threads. Can you explain precisely why you view them as "otherworldly"?
Re:Networking I/O with Virtual Threads – Under the hood
by DaiPlusPlus on Friday July 09, 2021 @06:53AM
(#27782378)
"Async/await is always strictly harder to use than green threads"
I'm sorry but I can't take you seriously after you say something like that.
What's being introduced now is a way to use that API without needing to touch the whole concept of async code. From the developer's perspective blocking calls and threads is pretty nice. It's async that's awkward and hard to use. Making the existing threads facility scale much better is a very clean approach: virtual threads introduces "virtually" no new concepts at all, in fact, if you aren't working with native code via JNI or Panama then you can act as if virtual and physical threads are the same. You literally just upgrade Java and maybe flip a couple of switches and you can now assign one thread per connection yet handle millions of connections (assuming you don't run out of other resources of course).