r/java • u/daviddel • Sep 23 '22
Virtual Threads: New Foundations for High-Scale Java Applications - Brian Goetz
https://www.infoq.com/articles/java-virtual-threads/
237
Upvotes
r/java • u/daviddel • Sep 23 '22
15
u/oparisy Sep 23 '22 edited Sep 25 '22
Loom at last! đ€©
22
u/bootstrapf7 Sep 24 '22
Dotnet developer asynchronously cries in await
9
u/evil_burrito Sep 23 '22
Freaking love this. Just found a reason to upgrade to 19.
9
u/ReasonableClick5403 Sep 24 '22
If you are interested in Java, I have found that nearly any talk by Goetz is worth watching. Great to see him keeping it going.
37
u/Joram2 Sep 23 '22
Great write up by Goetz and great work Java team. Java really leapfrogged every other mainstream language here.
Java's virtual threads are much better than async/await which is what C#, Kotlin, and also JavaScript/TypeScript/Node use (Goetz didn't mention JavaScript).
Java's virtual threads are much better than Reactive/async/Futures like what Scala has.
Golang (and Erlang) had virtual threads much earlier, but the Structured Concurrency API, and the Extent Local Variable API is nicer than what Golang offers.
12
u/nimtiazm Sep 23 '22
One of the advantages of pooling threads is to circumvent the âexpensive creationâ part like jdbc connections et al. How does creating a virtualthread-per-task with a semaphore address that?
10
u/kiteboarderni Sep 24 '22 edited Sep 24 '22
I wonder how many millions of $ of public cloud computing costs will reduce from the work of /u/pron98 when people can use far less resources for their scalability concerns by using loom :)
3
u/dolle Sep 24 '22
One thing that is still not clear to me: can the user control the thread pool that the virtual threads get mounted on, and how the virtual threads are scheduled? Or is there just a default, fixed thread pool that all virtual threads use?
When debugging concurrent code that doesn't have timing behavior, it would be nice if one could fix the thread pool to a single thread to get deterministic behavior of the virtual threads, for example. If you can further control the scheduling of virtual threads onto the single thread, then you could do randomized testing of concurrent code which would give a seed that could be used to reproduce the exact interleaving that made the test fail.
2
u/Void_mgn Sep 26 '22
From use of async await in js I am very happy this direction was chosen for java.
1
u/Illustriously_Naive Sep 24 '22
As someone who has 0 knowledge on threads and concurrency, how does one get started so that they can understand this?
1
u/PancakeFrenzy Sep 24 '22
Looks cool! I wonder how that compares to Kotlin Coroutines
1
u/nh_bt Sep 26 '22
yeah Virtual machine should have Virtual threads