Java 21 new feature: Virtual Threads

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

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

  • @Parkhill57
    @Parkhill57 ปีที่แล้ว +38

    the piano is driving me crazy

    • @vladimirdyuzhev
      @vladimirdyuzhev 15 วันที่ผ่านมา +1

      There is a whole asylum of us now.

  • @konstantinatwork3105
    @konstantinatwork3105 ปีที่แล้ว +12

    Awesome video. Very well structured and presented!

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

      Glad you liked it!

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

    If Mr. José Paumard is not an actor, maybe he should. This video is pretty funny!!! 😅
    Nice to get a chance to delve into such complex content in a lighter and interesting way.
    Thank you, José 👏👏👏

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

    Perfect presentation ! Thank you ! Pretty that sonar don't support it yet .. hope it is coming soon.

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

    Great Explanation ! Thank you

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

    Oh là là, une magnifique explication! merci!

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

    Thank you so much for your excellent presentation, Sir!
    Please give me some short explanations regarding the differences between Virtual Threads and the NIO mechanism.
    I appreciate your time.

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

    Very clear and nice explanations. Well done !

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

    Thanks José!

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

    fisrt time i see you , i use to read "java le soir " blog articles !

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

    How virtual threads are better than non-blocking I/O (Java NIO) created 20 years ago and extensively used today?

    • @abyssalwitch-b3h
      @abyssalwitch-b3h หลายเดือนก่อน

      nio requires so mich code change it mightnt worth it

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

    why dont you introduce async await instead completedfuture mess ? :D

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

    Wow!

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

    Is it true that virtual threads (called green threads) were already present in java 1.1 but then abandoned in 1.3 as too limiting? Could you please elaborate on what was consider the limitation then and how these limitations are overcome with this new implementation?

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

      Green threads were indeed an attempt at doing the same kind of things. But they were not working in the same way. One of the major difference was that a green thread was actually bound to a single platform thread, and could not jump from one another. There were other caveats, and in the end green threads were removed from the platform.
      Virtual threads are a totally new feature, with the same ideas in mind, but implemented in a complete new way.

  • @peace336-n8g
    @peace336-n8g 11 หลายเดือนก่อน

    One stupid question may be, What a raw implementation of creating a platform/kernel thread would like? If I want to create a platform/kernel thread without depending on Thread class how can i do it? Just curious to know if it is documented somewhere to read internals.

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

    12:49 In this mess how can i check that?

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

    content is too good, however the piano background music is driving me crazy. Anyway thanks Jose

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

    How many cups of coffee have you been drinking, sir?

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

      One. Just one, really 😄

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

      @@JosePaumard Your presentations are amazing, sir. Keep up the good work 👍

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

      @@VuLinhAssassinThank you!

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

    Is any guess when Oracle will make normal modern docs site like Kotlin, JS,Python has? JavaDocs is ugly

  • @DoubleM55
    @DoubleM55 ปีที่แล้ว +62

    FInally! We can just let our threads block on IO, as God intended!!!

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

      My first thought watching this was "oh god, no".

  • @yemzibossa
    @yemzibossa ปีที่แล้ว +44

    Your page becomes my number #1 source of learning Java faster. I love to always watch this channel. Thanks for all you do, Sir.

  • @leolewis7754
    @leolewis7754 ปีที่แล้ว +13

    Thanks José for presenting this in such an easy way to understand, especially on the limitations of the system. I did read in some places that synchronized code would always be pinned to a platform thread which was detering me from investigating moving to jdk 21 to benefit from virtual threads given the fair amount of synchronized code we unfortunately have in our legacy applications. But I will now revisit that plan with the information you provided. Thanks again

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

      Thank you! Glad I could help!

  • @andikovi1286
    @andikovi1286 ปีที่แล้ว +8

    Never heard anybody else explain in such a detailed and simple/friendly way. Congratulations!

  • @laurentjeanpierre3662
    @laurentjeanpierre3662 ปีที่แล้ว +8

    Thanks, Jose.
    I think your explanations are just at the right balance between technical and understandable. Your shorts are almost the only shorts I watch on TH-cam! Please keep on that way.
    I also need a copy of your mug of coffee, for it seems to empty itself only at the end of your task ;-).
    Merci !

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

      Thank you Laurent!

  • @natbirchall1580
    @natbirchall1580 ปีที่แล้ว +5

    This is why I stick with java. The quality of people working on it is amazing.

  • @AyushmanAdhikary
    @AyushmanAdhikary 24 วันที่ผ่านมา +2

    Very informative and insightful as always. Highly grateful to have been instructed by you on TH-cam and other platforms.

    • @java
      @java  23 วันที่ผ่านมา +1

      Great to hear!

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

    Clarifying question: 28:43, is this saying IO inside parallelStreams is/was always a bad idea… or is the point that it’s only a bad idea *now that Virtual Threads exist*?

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

      Always been a bad idea. Remember, its using a thread *somehwhere* its just doing the bookkeeping for you. By default, you'll share the same thread pool w/all parallel streams in your app. That means you could starve the pool intended for CPU bound tasks (like `sum()`) while its waiting for IO

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

      @@adambickford8720 that makes sense. Just so I’m clear, for those at or below Java 17, is the recommended alternative to use a separate, dedicated thread pool for scheduling and orchestrating blocking IO?

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

      ​@@2k5325i Exactly right. Its also perfectly fine to block those I/O threads as that's the intent and it won't 'starve' other threads. It normal to have far more I/O threads than cores. Just remember each thread takes memory and overhead to manage, even if idle.
      If you're CPU bound, more threads than cores makes things worse, not better, virtual or not.
      Remember that you'll potentially want to pool connections too and now you have to multiplex threads to connections.
      It never ends :)

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

    Thank you .. but could you please please please mute the background music as it is distracting and irritating. The music is unnecessary for this type of content. Content itself is great but the music makes it feel like when you are studying for an exam and you hear blast of TV noise coming from the other room.Thanks again

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

      Maybe low the volume little bit or some other types of music.

  • @PravinJain-i1q
    @PravinJain-i1q ปีที่แล้ว +6

    Thanks José for making this video,
    Really easy to understand the mechanics of Virtual Threads, how they work under the hood.

  • @usern90210
    @usern90210 ปีที่แล้ว +5

    Absolutely fantastique explainer as usual! Also so excited for Java 21 :D
    But as an aside, please, please, remove the white flashing transitions. It hurts my old eyes and I can think that folks with photo-sensitivity or epilepsy can have a hard time with these as well.
    Cheers,
    Niss

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

      Thank you Niss! I wasn't aware of this problem with flashing transitions, thank you for reporting. I will change that in the next videos.

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

      Merci Infinimenent@@JosePaumard
      Always a pleasure to follow your vids ^__^

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

    Can I have a cup of ur coffee sorry I am too excited about features

  • @christoph9198
    @christoph9198 ปีที่แล้ว +5

    Very great explanation. Emphasized and repeated the important parts. 😀

  • @D0gma
    @D0gma ปีที่แล้ว +7

    Continue ton super travail José ;)

  • @AleksandarT10
    @AleksandarT10 ปีที่แล้ว +7

    Greatly and well presented. Keep up the good work Jose! We need more on this topic

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

      Thank you! I will publish more when we have the new version of Structured Concurrency. Stay tune!

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

    José, I am becoming addicted to your cup of Java 🙂

  • @MrSurprise777
    @MrSurprise777 9 หลายเดือนก่อน +2

    Very great and detailed explanations of the topic!
    Thanks!

  • @Aditya-k9d
    @Aditya-k9d หลายเดือนก่อน

    Hi @Java / @JosePaumard, I want to understand the following -
    1. How is it ensured that all the blocking operations invoked by any arbitrary code (excluding native method calls and synchronized blocks) from a virtual thread are managed by the Continuation framework? Have all the potential blocking points in the JDK been identified and adapted to support this?
    2. Consider a third-party library that is confirmed not to use native methods or synchronized blocks. While calling it from a virtual thread, is it still necessary to manually verify that it will not accidentally block the underlying platform thread?
    Thanks.

  • @nickngn
    @nickngn 9 หลายเดือนก่อน +3

    Nothing to say except: "Awesome!"

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

    If my project is using java8 and upgrade to java21, will my old blocking code run in a virtual thread be pinned back to the platform thread? (old code includes old libraries like JDBC, GRPC, REST CLIENT)

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

    "You're not doing I/O in your parallel streams, right?". Oh God, thankfully not. 😅 Very good video.

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

    Perfect! Thank you, Sir!

  • @ievgen.official
    @ievgen.official 4 หลายเดือนก่อน

    Thanks. Great explanation of main topic plus extra tips. My ears satisfied when I've heard about IO in parallel computation.
    You said that stack is copied into the heap space. Stack is stored in RAM in stack memory. To me Java can simply keep all stacks in place, and switch between them by overriding a pointer to current stack in OS thread.
    Does it really need to be copied?

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

    Excited to dig into this

  • @YvesDautremay
    @YvesDautremay ปีที่แล้ว +5

    Merci José, super intéressant !

  • @RicardoSilvaTripcall
    @RicardoSilvaTripcall ปีที่แล้ว +5

    Great Explanation !!!

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

    ForkJoinTask and ForkJoinPool is tgere to do light weight concurrent Thread execution but why Virtual Threads again?

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

    The captions on this seem to be for a different video, kinda confusing 😶

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

      Thank you for reporting it! It should be fixed now.

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

    I liked to listen the before and after virtual threads, it makes much clear everything.

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

    Does In-memory computation mean a task for CPU bound job? If so, computing some tasks with virtual thread isn't good cuz virtual thread has more overhead than planform thead. (of course virtual thread is way much better when it comes to blocking). Do I get right?

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

      Yes. Virtual threads are only interesting if your task blocks.

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

    You had been drinking that tea for 33 mins. Wasn't that cold?

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

    Measure. Don't guess.

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

    wow, an absolutely masterfully extended way of saying: "cheaper threads, to better hide the complexity of asynchroneous". I was just wondering why not Promises, but Virtual Threads (with essentially non-public async framework) instead. Now i know. Thanks

  • @AbhishekKumar-xr1ss
    @AbhishekKumar-xr1ss 5 หลายเดือนก่อน

    can anyone explain what does "that would include the probable context switching that you will have to pay" mean at 28:12 ?

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

    wonderful presentation jose. cant wait to start using this. Why are we not supposed to call an IO operation or say a rest api calls in parallel streams? is there any reasons?

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

      Thank you!
      I/O operations in intermediate or terminal methods of streams: it's probably not working as you think. Same for parallel streams, you don't have any hand on how your data will be split, and to which point. So it gives a pretty unpredictable way of computing things.
      Pulling data from an I/O source: that's ok, this is what reader.lines() is doint. Don't do it in parallel though, it's useless.

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

    Great explanation master
    Gracias!

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

    Read my earlier post please and please help me to answer following question:"Why does Java sais that it invented something called virtual threads, when it was invented many years ago for C? How can something that is allready invented be invented again?"

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

      Sorry but I don't think Java ever said that it invented Virtual Threads. Where did you saw that?

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

      @@JosePaumard Sorry for my not correctly using the english language. I am not used to it 100%. I try my best. You are right that Java can't speak :-))) What I meant was the project and or company of course. I repeated looking the video again. It is said that JDK introduced Virtual Threads. So this does not mean that they invented it. So you are right virtual threads are not an invention of Java (project/company). Thank for helping to clearify this point. In short:"Virtual threads were not invented by JAVA (project/company.) Best regards.

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

      @@nejathakan5521 We agree: Java can't speak :-))) Best!

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

    Very nice new feature! Thanks. Is there some chance to see in Java mechanism like in C# async/await?

    • @Iulefaitdesvidos
      @Iulefaitdesvidos ปีที่แล้ว +9

      No, virtual threads were created not to have the async await pattern.
      It solves this bad pattern in languages, where there are async methods and others not, because when you start to have a method with async it contaminates the others. Like when you use reactive patterns with Flux, RxJava, CompletableFuture..

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

    Amazing talk! Really complete and comprehensive! Thank you for that.

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

    great explanations! thanks

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

    frontend with java.. why not?

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

    where can i get that java cup, please?

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

    Performance vs classical threads is so disappointing. There is nearly no diff

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

      There is no reason that your code run faster on virtual threads. In the end, it is a platform thread that executes your virtual thread. What you should run in a virtual thread is I/O operations. Then you will get better performances, because blocking is handled in a much better way than asynchronous code.

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

    Great solution for i/o ops.

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

    Thanks your great talk!
    so... should we worry about the platform threads are enough, how can we observe it, eg: queue size, active thread number...

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

    Amazing explanation...José Explaining both approaches and doing it so well with code is as always great.

  • @PavanKumar-IT
    @PavanKumar-IT 3 หลายเดือนก่อน

    Wow.. Loved your session. Super knowledgeable. Thank you very much

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

    😂

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

    Merci Beucoup

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

    but this feature isnot new. it was produce in
    java 19

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

      Yes. The new thing is that it is now a final feature. And there were some updates too.

  • @Andi-dp9hy
    @Andi-dp9hy ปีที่แล้ว +1

    Best loom explanation 👌

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

    subtitles are totally unrelated...🤣🤣

    • @JosePaumard
      @JosePaumard ปีที่แล้ว +5

      I just fixed them. Sorry for the inconvenience.

  • @yordanov5.0
    @yordanov5.0 7 หลายเดือนก่อน

    Magnificent explanation of pure engineering art. "Project Loom" is indeed a revolutionary masterpiece. 👏👏👏

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

    Awesome explanation

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

      Glad you think so!

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

    Best ever.

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

    obrigado José!

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

    Awesome explanations sir....Really nicely explained in plain simple language....

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

    Thank you, that was a great breakdown, I like to see more presentations from this guy again.

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

    Clean code, makes wonder what I have always been writing 😢

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

    Awesome video, thank you very much 😊

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

    Very great explanation! Thank you sir

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

    Amazing feature! Thanks for the explanation too!!

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

    Good explanation as always, thanks a lot for these videos

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

    José thanks for this clear explanation!

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

    Your coffee makes me wants to make a cup of coffee :)

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

    I like when this gentleman takes a sip of his coffe!!!

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

    he holding java coffee is just 💥💥💥

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

    He explained it so clearly. Bravo

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

    Coffee cup, that's just classy

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

    Great video thank you

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

    thx for this introduction

  • @geneb.4301
    @geneb.4301 ปีที่แล้ว +4

    I've been working with Reactor for three years now, and while Reactor is an excellent framework, the price to pay for creating and maintaining asynchronous software is huge. This change comes not a moment too soon.

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

      tickering reactor is a lot of fun, but not so much when comes to production and teamwork. The virtual thread makes reactor useless to me the moment I found it.

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

    good explanation

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

    how do you launch 2 or more io ops in parallel and wait for both like when parts of your data flow fan out and fan in

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

      That's the job of structured concurrency. It is still in preview in 21, reason why I chose not to cover it here.
      You can watch how it is working on this channel: th-cam.com/video/2nOj8MKHvmw/w-d-xo.html

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

    Thank you for this - that coffee must have been getting cold by the end

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

      Not quite, that's a good cup, it can keep the coffee warm for long enough 😉

  • @--Nath--
    @--Nath-- ปีที่แล้ว

    Hrm.. so would reactive mechanisms need to bother with all that they do? Or just use these for the blocking stuff?

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

      Use them for the blocking stuff. And ask yourself: do you need to write your code in an async way. Maybe you don't.

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

      @JosePaumard yeah, it does seem like these frameworks do a lot of complicated stuff to decouple concurrent tasks from threads to try deal with blocking stuff, which is what virtual threads do.

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

      @@--Nath-- Exactly.

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

    Please remove background music.

  • @perrinnjietche463
    @perrinnjietche463 2 วันที่ผ่านมา

    What a nice way to explain java virtual threads. 👏 Thanks Jose !
    Fun fact... I once run I/O in parallel Streams !🥲

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

    would have been nice to have a video without the music 😅

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

    Why Germans are so good at everything