Java Virtual Threads - Reactive Programming Killer?

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น •

  • @viraj_shetty
    @viraj_shetty  ปีที่แล้ว +4

    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

    • @fabriciosimoncelli
      @fabriciosimoncelli ปีที่แล้ว

      Hi Viraj! Is the course available for udemy business? I have a Udemy account from my company but I didn't find it

    • @viraj_shetty
      @viraj_shetty  ปีที่แล้ว +1

      Hi Fabricio - Unfortunately no. If you send a message and request to Udemy, they might add it hopefully.

    • @viraj_shetty
      @viraj_shetty  ปีที่แล้ว +1

      Hi Fabricio - Good News. Its now available as of yesterday ! Thanks !

    • @fabriciosimoncelli
      @fabriciosimoncelli ปีที่แล้ว +1

      @@viraj_shetty awesome!! I've just enrolled. Thank you so much 👏

  • @MoshlehuddinMazumder
    @MoshlehuddinMazumder 10 หลายเดือนก่อน +5

    Very precise explanation. Kudos! Would love to see some work around migrating from Spring webflux to virtual thread.

  • @CristianPopescu-i5w
    @CristianPopescu-i5w ปีที่แล้ว +7

    Great explanation! Thank you for taking the time to do this

  • @daveamiana778
    @daveamiana778 ปีที่แล้ว +4

    I enjoyed the explanation. Thank you for putting out this content; really helped me wrap my head around this concept.

  • @picktube34993
    @picktube34993 หลายเดือนก่อน

    Great explanation! looking forward to more contents from you..

  • @wdeath
    @wdeath 8 หลายเดือนก่อน +1

    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.

    • @viraj_shetty
      @viraj_shetty  7 หลายเดือนก่อน

      This discussion is for UI applications. Some use cases probably will continue using reactive style - like data pipelines . I agree there

  • @amitbhattacharyya7701
    @amitbhattacharyya7701 ปีที่แล้ว

    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

    • @viraj_shetty
      @viraj_shetty  ปีที่แล้ว +1

      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 !

  • @tulsiakashahida
    @tulsiakashahida หลายเดือนก่อน

    Superb tutorial Viraj.

    • @viraj_shetty
      @viraj_shetty  หลายเดือนก่อน

      Glad you liked it

  • @sadiulhakim7814
    @sadiulhakim7814 3 หลายเดือนก่อน +1

    10:55 Automatic switching is cool

    • @viraj_shetty
      @viraj_shetty  3 หลายเดือนก่อน

      I think so too

  • @yogeshbhakhar3414
    @yogeshbhakhar3414 ปีที่แล้ว +1

    Thank you for this. Simply Amazing❤

  • @sadiulhakim7814
    @sadiulhakim7814 3 หลายเดือนก่อน

    Thanks for this video. By the way your Virtual Threads course is best out there.

    • @viraj_shetty
      @viraj_shetty  3 หลายเดือนก่อน

      Glad you think so!

  • @GodofStories
    @GodofStories ปีที่แล้ว +1

    Excellent presentation, really explained it well.

  • @akshaykapadia8359
    @akshaykapadia8359 4 หลายเดือนก่อน +1

    Do we need additional config to use virtual threads in spring boot project when we upgrade to java 21?

    • @viraj_shetty
      @viraj_shetty  4 หลายเดือนก่อน

      By default platform threads would be used but you can set a property to use virtual threads

  • @shazinfy
    @shazinfy ปีที่แล้ว +1

    Excellent Explanation. Thanks.

  • @roysarit
    @roysarit ปีที่แล้ว

    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?

    • @viraj_shetty
      @viraj_shetty  ปีที่แล้ว +1

      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

  • @duybuiha9284
    @duybuiha9284 7 หลายเดือนก่อน

    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.

    • @viraj_shetty
      @viraj_shetty  7 หลายเดือนก่อน

      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

  • @MrKKPA
    @MrKKPA 10 หลายเดือนก่อน +1

    How is the memory allocation of the objects used with carrier threads?

    • @viraj_shetty
      @viraj_shetty  10 หลายเดือนก่อน +1

      Carrier thread is basically a Platform thread, so all objects are allocated in the heap. No change.

    • @MrKKPA
      @MrKKPA 10 หลายเดือนก่อน

      @@viraj_shetty I love your content! Thank you!

  • @abcd-sf5ur
    @abcd-sf5ur 9 หลายเดือนก่อน +1

    Splendid explanation.

    • @viraj_shetty
      @viraj_shetty  8 หลายเดือนก่อน

      I am glad you liked it

  • @Ranjith_P
    @Ranjith_P 3 หลายเดือนก่อน

    Great series 👏

    • @viraj_shetty
      @viraj_shetty  2 หลายเดือนก่อน

      Glad you enjoyed

  • @sadiulhakim7814
    @sadiulhakim7814 3 หลายเดือนก่อน +2

    13:19 I am not going to use anymore

    • @viraj_shetty
      @viraj_shetty  3 หลายเดือนก่อน

      You can use Structured Concurrency classes when it gets out of preview if you need concurrency. Virtual Threads + Structured Concurrency is cool

  • @alexguitarwatson3215
    @alexguitarwatson3215 2 หลายเดือนก่อน

    Nice overview. Some code samples would have been nice, though

    • @viraj_shetty
      @viraj_shetty  2 หลายเดือนก่อน

      Thanks 🙏!

  • @sambaemol2476
    @sambaemol2476 6 หลายเดือนก่อน

    Thank you very much. You made it look so easy.

    • @viraj_shetty
      @viraj_shetty  6 หลายเดือนก่อน

      I am glad you enjoyed it

  • @andd3dfx
    @andd3dfx 7 หลายเดือนก่อน +1

    Thanks, looking helpful

    • @viraj_shetty
      @viraj_shetty  7 หลายเดือนก่อน

      You are welcome !

  • @AkshatMehra-l4b
    @AkshatMehra-l4b 6 หลายเดือนก่อน

    Great video. Pretty sure never learned so much in just 13 mins 😉

    • @viraj_shetty
      @viraj_shetty  6 หลายเดือนก่อน +1

      Glad you enjoyed it! 😊

  • @manuyaji
    @manuyaji ปีที่แล้ว +2

    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?

    • @viraj_shetty
      @viraj_shetty  ปีที่แล้ว +3

      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.

    • @fedorkonstantinov2497
      @fedorkonstantinov2497 11 หลายเดือนก่อน

      At the same time those 200 threads could fetch only, e.g., 200 db conections, but now they will exhaust the db connection pool

  • @jamilxt
    @jamilxt ปีที่แล้ว +1

    Thank you! 🎉

  • @RenannPrado
    @RenannPrado 11 หลายเดือนก่อน +1

    I hope so.

    • @viraj_shetty
      @viraj_shetty  11 หลายเดือนก่อน

      Except for the streaming part of the reactive architecture, i think other parts are replaceable

  • @badbaboye
    @badbaboye 11 หลายเดือนก่อน +1

    thank you for the video

    • @viraj_shetty
      @viraj_shetty  11 หลายเดือนก่อน

      Glad you enjoyed

  • @bablushaw2884
    @bablushaw2884 4 หลายเดือนก่อน

    Very nice explanation.

  • @KushanSamaranayake-o3y
    @KushanSamaranayake-o3y ปีที่แล้ว +1

    Thank you Viraj

  • @girishanker3796
    @girishanker3796 5 หลายเดือนก่อน

    Great video

    • @viraj_shetty
      @viraj_shetty  5 หลายเดือนก่อน

      Thanks! Glad you liked it

  • @ArunKumar-fw6lu
    @ArunKumar-fw6lu 9 หลายเดือนก่อน +1

    Great explanation for thread concepts

    • @viraj_shetty
      @viraj_shetty  9 หลายเดือนก่อน

      Glad you enjoyed !

  • @khalidhamid7448
    @khalidhamid7448 8 หลายเดือนก่อน +5

    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.

    • @viraj_shetty
      @viraj_shetty  8 หลายเดือนก่อน

      That’s definitely an option.

    • @DielsonSales
      @DielsonSales 7 หลายเดือนก่อน +2

      Unfortunately it’s not always the choice of one developer.

    • @simonhartley9158
      @simonhartley9158 6 หลายเดือนก่อน +2

      Suspend functions and flow wrappers have the downside of function coloring.

    • @andreyv116
      @andreyv116 4 หลายเดือนก่อน

      ​@@simonhartley9158I was just about to mention the function coloring issue with suspend functions

    • @lhxperimental
      @lhxperimental 16 วันที่ผ่านมา +1

      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

  • @RuslanKhamitov-l2w
    @RuslanKhamitov-l2w 6 หลายเดือนก่อน +1

    Excellent explanation, thank you!

    • @viraj_shetty
      @viraj_shetty  6 หลายเดือนก่อน

      I am glad you enjoyed the video