Hi All - Use link below for my popular Java courses. Virtual Threads - www.mudraservices.com/udemycoupon.html?course=vthread Java Generics - www.mudraservices.com/udemycoupon.html?course=jgen For more of my courses, check out - www.mudraservices.com
Data process and real time data processing, will define how we make our applications. Its not just the async, reactive programming is about data processing in pipelines. I think betting on data is always safe, before some years we didn't even have data-engineers now they are everywhere, this will come to software also.
That's the first thought came in my mind when I came across virtual thread , however on 8:08 , fully reactive design do you mean future and completablefuture can you point to some git repo for better understanding to active reactive design in java 8 for example
Your instinct is correct. Java provides frameworks for writing Reactive applications. CompletableFuture (not Futures) and Spring WebFlux are two such mechanisms. But they don't mandate that the code is "Fully Reactive" because developers can always write blocking code and nothing can prevent that. Being fully reactive would require Developer due diligence as well. This video is more of a general discussion on reactive programming. I am creating a new video with code samples and I will publish that soon. Thanks for your comments !
Thank you for the beautiful explanations. I want to understand thread life cycle in reactive programming in a more deeper way. Is there any resource I can refer to?
Check out the CompletableFuture tutorial. This talks about thread use. - 90 mins FREE Tutorial on Java Futures and Completable Futures th-cam.com/video/PrhquBepY4c/w-d-xo.html
Hi Viraj, should we refactor reactive code style to synchronize code and upgrade spring webflux to virtual thread? Is there something reactive can do and do better than virtual thread? r2dbc, callback event ?, stream composition and transformation ?, Thanks.
My suggestion is to NOT rewrite your reactive application. But your next application should be evaluated to see if you can use Virtual threads. Currently Real time streaming data is the only thing which reactive programs can do better. If so, only that part should be made reactive. That's my thought ! Its an interesting video to make
Hi Viraj, I had a question. The reason why we simply don't scale the number of platform threads in our application is because it consumes ~1 MB per thread. How does having virtual threads solve that problem?
Platform threads don't scale well. That's why we usually pool the Platform threads - say 200 max. That means if 5000 users are concurrently hitting your tomcat server - only 200 at time will be handled and that leads to severe performance problems (unless you add more tomcat instances). But the CPU is not maxed out at this point, so basically resources are not utilized properly. For the same requests, if you use Virtual Threads - there will be 5000 Virtual threads. Virtual threads are cheap, consumes memory in kbytes and under the hood they use Platform thread (Carrier) for CPU operations. But the important thing is that Virtual thread releases the carrier thread during IO operations like network io, file read/writing or locking. So, these 5000 Virtual threads will require only a few Platform threads (approx = num of cores). This improves the CPU throughput considerably. Virtual threads give us an illusion of more actual threads just like Virtual Memory gives us an illusion of more physical memory.
Why not switch to Kotlin instead, it has coroutines (structured concurrency), flows ( reactive pipelines), it’s not verbose as Java, first class support out of Spring, interoperable with Java libraries, don’t need Lombok, you can leverage KSP for faster compilation or to write plugins, you can use functional style programming with Arrow library, small learning curve plus once you get use to it you can write your own DSL. I did Java for a decade then Kotlin now again Java. It’s just feels like I’m going backwards when doing Java.
Because Kotlin was born out of Google's need to protect itself from Oracle for using Java in Android. When you don't have the baggage of the past it's easy to innovate so it's not surprising that it has a few extra features. But JVM based languages other than Java are essentially experiments. The successful ones will be absorbed into java and failed ones will be forgotten. Scala was big a decade ago, where is it now? Your time is better invested in learning something completely different like AI/ML, Kubernetes etc. than learning a variant of a mainstream language. There is a lot i have learnt over the decades. Many of those technologies don't even exist today. But I can still read C and make sense of Java. There is value in stability
Hi All - Use link below for my popular Java courses.
Virtual Threads - www.mudraservices.com/udemycoupon.html?course=vthread
Java Generics - www.mudraservices.com/udemycoupon.html?course=jgen
For more of my courses, check out - www.mudraservices.com
Hi Viraj! Is the course available for udemy business? I have a Udemy account from my company but I didn't find it
Hi Fabricio - Unfortunately no. If you send a message and request to Udemy, they might add it hopefully.
Hi Fabricio - Good News. Its now available as of yesterday ! Thanks !
@@viraj_shetty awesome!! I've just enrolled. Thank you so much 👏
Very precise explanation. Kudos! Would love to see some work around migrating from Spring webflux to virtual thread.
Noted
Great explanation! Thank you for taking the time to do this
Glad it was helpful!
I enjoyed the explanation. Thank you for putting out this content; really helped me wrap my head around this concept.
Glad it was helpful!
Great explanation! looking forward to more contents from you..
Data process and real time data processing, will define how we make our applications.
Its not just the async, reactive programming is about data processing in pipelines.
I think betting on data is always safe, before some years we didn't even have data-engineers now they are everywhere, this will come to software also.
This discussion is for UI applications. Some use cases probably will continue using reactive style - like data pipelines . I agree there
That's the first thought came in my mind when I came across virtual thread , however on 8:08 , fully reactive design do you mean future and completablefuture can you point to some git repo for better understanding to active reactive design in java 8 for example
Your instinct is correct. Java provides frameworks for writing Reactive applications. CompletableFuture (not Futures) and Spring WebFlux are two such mechanisms. But they don't mandate that the code is "Fully Reactive" because developers can always write blocking code and nothing can prevent that. Being fully reactive would require Developer due diligence as well.
This video is more of a general discussion on reactive programming. I am creating a new video with code samples and I will publish that soon. Thanks for your comments !
Superb tutorial Viraj.
Glad you liked it
10:55 Automatic switching is cool
I think so too
Thank you for this. Simply Amazing❤
Appreciate it very much
Thanks for this video. By the way your Virtual Threads course is best out there.
Glad you think so!
Excellent presentation, really explained it well.
Glad you liked it !
Do we need additional config to use virtual threads in spring boot project when we upgrade to java 21?
By default platform threads would be used but you can set a property to use virtual threads
Excellent Explanation. Thanks.
Glad you enjoyed
Thank you for the beautiful explanations. I want to understand thread life cycle in reactive programming in a more deeper way. Is there any resource I can refer to?
Check out the CompletableFuture tutorial. This talks about thread use. - 90 mins FREE Tutorial on Java Futures and Completable Futures
th-cam.com/video/PrhquBepY4c/w-d-xo.html
Hi Viraj, should we refactor reactive code style to synchronize code and upgrade spring webflux to virtual thread? Is there something reactive can do and do better than virtual thread? r2dbc, callback event ?, stream composition and transformation ?, Thanks.
My suggestion is to NOT rewrite your reactive application. But your next application should be evaluated to see if you can use Virtual threads. Currently Real time streaming data is the only thing which reactive programs can do better. If so, only that part should be made reactive. That's my thought ! Its an interesting video to make
How is the memory allocation of the objects used with carrier threads?
Carrier thread is basically a Platform thread, so all objects are allocated in the heap. No change.
@@viraj_shetty I love your content! Thank you!
Splendid explanation.
I am glad you liked it
Great series 👏
Glad you enjoyed
13:19 I am not going to use anymore
You can use Structured Concurrency classes when it gets out of preview if you need concurrency. Virtual Threads + Structured Concurrency is cool
Nice overview. Some code samples would have been nice, though
Thanks 🙏!
Thank you very much. You made it look so easy.
I am glad you enjoyed it
Thanks, looking helpful
You are welcome !
Great video. Pretty sure never learned so much in just 13 mins 😉
Glad you enjoyed it! 😊
Hi Viraj,
I had a question.
The reason why we simply don't scale the number of platform threads in our application is because it consumes ~1 MB per thread.
How does having virtual threads solve that problem?
Platform threads don't scale well. That's why we usually pool the Platform threads - say 200 max. That means if 5000 users are concurrently hitting your tomcat server - only 200 at time will be handled and that leads to severe performance problems (unless you add more tomcat instances). But the CPU is not maxed out at this point, so basically resources are not utilized properly.
For the same requests, if you use Virtual Threads - there will be 5000 Virtual threads. Virtual threads are cheap, consumes memory in kbytes and under the hood they use Platform thread (Carrier) for CPU operations. But the important thing is that Virtual thread releases the carrier thread during IO operations like network io, file read/writing or locking. So, these 5000 Virtual threads will require only a few Platform threads (approx = num of cores). This improves the CPU throughput considerably.
Virtual threads give us an illusion of more actual threads just like Virtual Memory gives us an illusion of more physical memory.
At the same time those 200 threads could fetch only, e.g., 200 db conections, but now they will exhaust the db connection pool
Thank you! 🎉
You are welcome !
I hope so.
Except for the streaming part of the reactive architecture, i think other parts are replaceable
thank you for the video
Glad you enjoyed
Very nice explanation.
Thanks 🙏
Thank you Viraj
Sure thing !
Great video
Thanks! Glad you liked it
Great explanation for thread concepts
Glad you enjoyed !
Why not switch to Kotlin instead, it has coroutines (structured concurrency), flows ( reactive pipelines), it’s not verbose as Java, first class support out of Spring, interoperable with Java libraries, don’t need Lombok, you can leverage KSP for faster compilation or to write plugins, you can use functional style programming with Arrow library, small learning curve plus once you get use to it you can write your own DSL.
I did Java for a decade then Kotlin now again Java. It’s just feels like I’m going backwards when doing Java.
That’s definitely an option.
Unfortunately it’s not always the choice of one developer.
Suspend functions and flow wrappers have the downside of function coloring.
@@simonhartley9158I was just about to mention the function coloring issue with suspend functions
Because Kotlin was born out of Google's need to protect itself from Oracle for using Java in Android. When you don't have the baggage of the past it's easy to innovate so it's not surprising that it has a few extra features. But JVM based languages other than Java are essentially experiments. The successful ones will be absorbed into java and failed ones will be forgotten. Scala was big a decade ago, where is it now? Your time is better invested in learning something completely different like AI/ML, Kubernetes etc. than learning a variant of a mainstream language. There is a lot i have learnt over the decades. Many of those technologies don't even exist today. But I can still read C and make sense of Java. There is value in stability
Excellent explanation, thank you!
I am glad you enjoyed the video