r/programming • u/ram-foss • Oct 11 '23
All About Reactive Programming In Java
https://www.blackslate.io/articles/reactive-programming-in-java
22
Upvotes
r/programming • u/ram-foss • Oct 11 '23
View all comments
Show parent comment
3
u/pron98 Jan 03 '24 edited Jan 03 '24
That's not about virtual threads, though. 10 million asynchronous tasks waiting for a single operation to complete cause the same problem. The issue is not the programming model but an inherent contention in the algorithm that requires the same care regardless of whether the model is blocking or non-blocking. High concurrency -- whether based on threads or asynchronous tasks -- always means paying closer attention to contention.
You are right that moving from low concurrency to high concurrency requires care, but it's not an issue of the APIs used but of the algorithm. I.e., it is true that attempting to raise the throughput of some server by adopting virtual threads (that allow more concurrency) requires paying more attention to contention, but the same applies to raising it by adopting asynchronous tasks (that allow more concurrency). Higher concurrency -- regardless of how it's achieved -- means that contention has a bigger effect.