Live data from Hacker News

Java Virtual Threads Preview

openjdk.java.net

1–10 of 270 posts

Re: Java Virtual Threads Preview

#3
Far fewer applications need this than many are led to believe. That said, this is always a welcome addition although this really doesn't add more than syntax over the stuff we've had in java.nio for a couple of decades

Re: Java Virtual Threads Preview

#4
post #3

Far fewer applications need this than many are led to believe. That said, this is always a welcome addition although this really doesn't add more than syntax over the stuff we've had in java.nio for a couple of decades

You can always write a callback oriented program, but this is much nicer!

Re: Java Virtual Threads Preview

#6
post #3

Far fewer applications need this than many are led to believe. That said, this is always a welcome addition although this really doesn't add more than syntax over the stuff we've had in java.nio for a couple of decades

You can always write a callback oriented program, but this is much nicer!

Yeah agreed. It is definitely very welcome syntax sugar and I'll take it over JS callback hell or async/await stuff any day. I just wanted to point out that non-blocking I/O has been available in Java for a long time so high I/O throughput applications have been possible to build in Java even though it required more mental overhead.

Re: Java Virtual Threads Preview

#7
post #5

I was going to say with modern PCs this is kinda redundant now, but its still a language of small devices too, where it'll be welcome.

This isn't really targeted for small devices - its very very applicable with large computers in datacenters (id argue those machines will benefit even more from this). Any time you wait on I/O you potentially park an entire thread when you could be multiplexing your threads. This is a net win for almost all users of threads (except perhaps 100% cpu intensive tasks)

Re: Java Virtual Threads Preview

#9
Really excited to see this! Seeing some of the early comments here I think folks may not realize how awesome this would be in the server space.

After all, a big reason that NodeJS won a lot of popularity on the server is that, for many types of common webserver workloads (i.e. lots of IO, relatively minor CPU usage), NodeJS can actually scale much better than Java with its thread-per-request model.

With these virtual threads, though, you could get the best of all possible worlds - a webserver that scales like NodeJS, but without some of the "CPU starvation" issues you can hit in Node if one executing request doesn't yield, and also without having to worry about "function coloring" like you do in Node with async vs. non-async functions.

Really, really fantastic development, have been waiting to see when this would come out.

Post reply on HN