Java Memory Model in 10 minutes

Поделиться
HTML-код
  • Опубликовано: 28 май 2024
  • Java Memory Model is a set of rules all JVMs have to follow to ensure correct working of our concurrent programs.
    More resources:
    2016.javazone.no/program/the-...
    shipilev.net/blog/2014/safe-p...
    www.cs.umd.edu/~pugh/java/mem...
    docs.oracle.com/javase/specs/...
    Channel
    ----------------------------------
    Complex concepts explained in short & simple manner. Topics include Java Concurrency, Spring Boot, Microservices, Distributed Systems etc. Feel free to ask any doubts in the comments. Also happy to take requests for new videos.
    Subscribe or explore the channel - / defogtech
    New video added every weekend.
    Popular Videos
    ----------------------------------
    What is an API Gateway - • What is an API Gateway?
    Executor Service - • Java ExecutorService -...
    Introduction to CompletableFuture - • Introduction to Comple...
    Java Memory Model in 10 minutes - • Java Memory Model in 1...
    Volatile vs Atomic - • Using volatile vs Atom...
    What is Spring Webflux - • What is Spring Webflux...
    Java Concurrency Interview question - • Java Concurrency Inter...
  • НаукаНаука

Комментарии • 203

  • @70ME3E
    @70ME3E 4 года назад +80

    I'm going through this playlist to learn Java concurrency, and I have to say your explanation and presentation quality are amazing, and the diagrams are really helpful.
    thank you!

  • @suhani091088
    @suhani091088 4 года назад +4

    Always read these topic therotically, but could never visualise it like this you have explained..Great presentation man!

  • @rohitsharma-xt8qe
    @rohitsharma-xt8qe 5 лет назад +8

    I have never seen such an excellent explanation of JMM. Thanks a lot

  • @monishchhadwa777
    @monishchhadwa777 3 месяца назад

    I would absolutely recommend all Java engineers-whether junior or very senior-to watch this!

  • @shellindebted5328
    @shellindebted5328 6 лет назад +16

    I tried multiple times myself to understand JMM,
    But this is the first time i got to learn something about them.
    Excellent Presentation.
    Hats of to you, You define perfection!!

    • @DefogTech
      @DefogTech  6 лет назад +1

      I am far from perfect. Though, thanks much for the kind words sir!

    • @yifei663
      @yifei663 5 лет назад

      May be you should read java language specification : docs.oracle.com/javase/specs/jls/se8/html/jls-17.html .

  • @Machinerium
    @Machinerium 5 лет назад +9

    I had an interview question like that.. This is a very clean explanation , keep doing it!

  • @NaturalPro100
    @NaturalPro100 5 лет назад +22

    The best video i could find on youtube.

  • @TauCu
    @TauCu 4 года назад +1

    This helped me understand a lot about the JVM Thanks, you're very good at explaining things without any unneeded gibberish!

  • @tanoysaha7410
    @tanoysaha7410 4 года назад +2

    Your explanations are precise, but have so in-depth/hidden informations and moreover so easy to understand

  • @mrchief3383
    @mrchief3383 3 года назад +5

    Man, you are awesome. I was struggling trying to understand atomic operations and the use cases of volatile variables. Thank you so much

  • @DrAkyla1123
    @DrAkyla1123 5 лет назад +3

    Very concise and easy to grasp. Great job!

  • @Admiral.MacDonnell
    @Admiral.MacDonnell 4 месяца назад

    My takeaway - if the tasks perform blocking IO operation, I should not use fork join pool. so true. Thanks for the explanation! You have a gift of mixing complicated concept easy to digest!

  • @skaLife
    @skaLife 4 года назад +1

    You have a good teacher in you. Please continue the good work.

  • @anilkinikar
    @anilkinikar 5 лет назад +1

    Awesome clarity. Voice is very clear and videos are well designed. Subscribed 👍

  • @viveksingh9120
    @viveksingh9120 5 лет назад +5

    Awesome mate. You are really doing great, very impressive

  • @rajasruji2476
    @rajasruji2476 2 года назад

    Wow…. Such an well articulated video. I felt this topic to be very difficult to understand before I watched your video. Please sir keep adding more and more topics to this channel. For the first time fell in love with subject videos.

  • @sandeepkumarsahoo3458
    @sandeepkumarsahoo3458 4 года назад

    Crystal clear explaination... Loved it

  • @sumitbabel5415
    @sumitbabel5415 3 года назад

    Honestly exceptionally well explained Sir, hats off

  • @paneerdopyaaza2914
    @paneerdopyaaza2914 3 года назад

    Please make a whole course...I will definitely try buying it.Your videos are just awesome.

  • @perrym8048
    @perrym8048 5 месяцев назад

    Best explanation I've seen, great work!

  • @iknowyourerightbut6246
    @iknowyourerightbut6246 5 лет назад +7

    future me:
    volatile has semantics for memory visibility. Basically, the value of a volatile field becomes visible to all readers (other threads in particular) after a write operation completes on it. Without volatile, readers could see some non-updated value.

  • @bhavyashah2630
    @bhavyashah2630 6 лет назад +59

    Awesome video...Please don't stop making such excellent videos.

  • @Dedeepya9
    @Dedeepya9 5 лет назад +5

    Started watching thread pool videos Nd then addicted to all of ur videos Nd subscribed..the way of explanation is precise , innovative Nd interesting.your wrk deserves more than a thnks..

    • @DefogTech
      @DefogTech  5 лет назад +2

      Thank you for the kind words!! I am so happy its helping everyone

    • @sepraveen
      @sepraveen 4 года назад

      Yes are techie by heart

  • @vikramreddy7586
    @vikramreddy7586 3 года назад +1

    This video is pure GOLD!!!

  • @kakashihatake4840
    @kakashihatake4840 6 лет назад +3

    Really loved the explanation. Thank you

  • @edeepakjain
    @edeepakjain 4 года назад +1

    Best explanation of volatile so far... 👌

  • @narendrasriram
    @narendrasriram 5 месяцев назад

    This playlist you have made is too awesome. your example/explanation for happens-before has a few issues. Not sure if I understood wrong, otherwise.Thank you so much for this playslit.

  • @Lucky-uz3je
    @Lucky-uz3je 5 лет назад +3

    You are my interview trainer...love you bro:)

  • @VikiSangani
    @VikiSangani 5 лет назад +2

    Very nicely explained. Please keep making such videos.👍👍

  • @prashanttiwari120
    @prashanttiwari120 3 года назад

    Best video on java on whole RUclips universe

  • @tarang65
    @tarang65 3 года назад

    Amazing presentation. All the videos are really helpful. Great work.

  • @nlarralde
    @nlarralde 2 года назад

    Great video, very clear explanation and examples. Thank you

  • @purnimadas3762
    @purnimadas3762 5 лет назад +4

    That was really good. Thanks for posting, excellent, clear and to the point presentation, good job!

  • @venu5791
    @venu5791 4 года назад

    Thanks for sharing this concept. I had only some theoretical knowledge of this before I watch this imp video.

  • @SatyaprasadMr
    @SatyaprasadMr 4 года назад

    Videos are very useful. Crisp & Clear. I request to make more videos

  • @kotojava
    @kotojava 2 года назад

    this channel deserve much more subscribers.

  • @thomashpfner-dahl1433
    @thomashpfner-dahl1433 5 лет назад

    Dude!! You are awesome, a true lifesaver. You are the first that have made it simple, at least that I have come across

  • @hakura88
    @hakura88 Год назад

    love your simple examples. thank you

  • @gauravbajpai6890
    @gauravbajpai6890 5 лет назад +1

    U earned a fan today - Subscribed !

  • @shobhitmittal77
    @shobhitmittal77 4 года назад +1

    This is one ultimate video...subscribed !!

  • @masteradityamishra9486
    @masteradityamishra9486 5 лет назад +2

    Very nice explanation appreciate it, thanks.

  • @ivanevseevv
    @ivanevseevv 3 года назад

    Explanation is very good and sharp!

  • @saravanprathi6956
    @saravanprathi6956 3 года назад +1

    You are a fantastic teacher.. please please make more videos

  • @noortech254
    @noortech254 3 года назад

    Bro You are simply amazing. You may be not realised how much you are helping us. Thank You bhai :D

  • @mujahidshaikh5034
    @mujahidshaikh5034 3 года назад

    everything to the point.. love ur videos bro❤️

  • @StyleTrick
    @StyleTrick 4 года назад +3

    Hey great videos as always! I just wanted to ask, since primitives are passed by value and Objects are passed as reference, does the JVM only cache primitives into a threads local cache? If the value being updated was an Integer Object, e.g. new Integer(1), it would not need flushing as the object is passed by REFERENCE?

  • @harish7706
    @harish7706 5 лет назад

    I have been going through a lot of JAVA topic videos in different forums, by far Defog Tech is the best that I have come across. Advanced topics explained in a simple way which provides clarity. Keep going

    • @DefogTech
      @DefogTech  5 лет назад

      Thank you for the kind words sir!

  • @abhik9450
    @abhik9450 4 года назад

    Thanks for a proper explanation on happens-before 🙂

  • @jeremythen7239
    @jeremythen7239 5 лет назад +2

    Best explanations! Keep it up.

  • @umeriqbal5662
    @umeriqbal5662 4 года назад

    Jigger u r love...
    Awesome video....
    Amazing teaching skills... Thanks a lot

  • @prasantkumar7693
    @prasantkumar7693 5 лет назад +2

    Thank you for nice explanation and make more videos.

  • @isayanpal
    @isayanpal Год назад

    You're just brilliant! 🙏🏽

  • @sshks10
    @sshks10 3 года назад

    Very good and simple explanation

  • @vijayp6810
    @vijayp6810 4 года назад

    Learnt new information..thank you so much

  • @pogrommist
    @pogrommist 3 года назад

    Awesome explanation and examples!

  • @MarkGla55
    @MarkGla55 2 года назад

    Excellent explanation. Thank you

  • @niftymiller6057
    @niftymiller6057 5 лет назад +4

    Very good and crisp way of explanation. Keep doing this good :) work

  • @__nitinkumar__
    @__nitinkumar__ 2 года назад

    2:50 loved this diagram man.

  • @studio2038
    @studio2038 4 года назад +1

    very simple to understand

  • @coreyhartman4510
    @coreyhartman4510 4 года назад +2

    This video is excellent.

  • @jiteshkumar3387
    @jiteshkumar3387 3 года назад

    Good explanation !! :) Very usefull

  • @ibrahimshaikh3642
    @ibrahimshaikh3642 3 года назад

    Thank u, waiting for more videos on java

  • @mehulmakwana7091
    @mehulmakwana7091 4 года назад

    Awesome explanation buddy. thanks a lot. :)

  • @ardiansyah6794
    @ardiansyah6794 4 года назад

    Oh thanks man. I wish you were my lecturer 😀

  • @Murga_Mutton
    @Murga_Mutton 3 года назад

    Hi, Thanks for the video.
    How is the volatile or synchronized or lock usage different from having the field in the constructor?
    Can't the shared cache object be used by putting the field in the constructor method and calling it in different threads?

  • @vijaykumarreddyt3287
    @vijaykumarreddyt3287 Год назад

    You are doing Great! Dude

  • @manognajoshik8465
    @manognajoshik8465 2 года назад

    Thank you very much sir!! You are amazing ❤️

  • @sivagurunathanparanitharan4714
    @sivagurunathanparanitharan4714 3 года назад

    🙏 You are the Best Teacher that I have ever seen.🥇, A classical method of approach = Superb indeed.👌.🎯Please Could you kindly teach us Flutter & Dart & Go lang & Scala too . Pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeese Sir..... 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

  • @sbylk99
    @sbylk99 5 лет назад +2

    Great tutorial, thank you SIR!

  • @Jayantch.999
    @Jayantch.999 3 года назад

    Super explanation 👍

  • @pkbkarpr
    @pkbkarpr 3 года назад

    Short and Sweet

  • @mostinho7
    @mostinho7 4 года назад +1

    2:10 each core has its own cache and then there are shared caches. Thread running on core changes the variable in its local cache only, volatile keyword makes sure variable is flushed to shared cache when thread changes it so that changes are visible to all the other threads
    6:05 happens before relationship
    9:30 volatile keyword example

    • @monstersmiled648
      @monstersmiled648 4 года назад

      Hi can you help me
      I am confused when i was trying real time as per the diagram in the time 00:03:52
      here i used this...
      System.out.println("the writerThread x is: "+x);
      System.out.println("the readerThread r2 is:"+r2);
      ---------------------------------------------------------------------------------------------------------------------------------
      like in this program(below):
      public class FieldVisibility
      {
      int x = 0;
      public void writerThread()
      {
      x = 1;
      System.out.println("the writerThread x is: "+x);
      }
      public void readerThread()
      {
      int r2 = x;
      System.out.println("the readerThread r2 is:"+x);
      }
      }
      output is:--
      the writerThread x is: 1
      the readerThread r2 is:1
      .......................................................................................
      instead of
      the writerThread x is: 1
      the readerThread r2 is:0

  • @SagarBorseTheGeek
    @SagarBorseTheGeek 5 лет назад

    Excellent explanation

  • @MoBeigi
    @MoBeigi 4 года назад

    Very good video, thank you!

  • @andrii5866
    @andrii5866 3 года назад

    Awesome. Thanks man!

  • @sriram6148
    @sriram6148 2 года назад

    Amazing!!! You rock!

  • @yxx5326
    @yxx5326 5 лет назад

    Thank you! Really like your explanation.

    • @DefogTech
      @DefogTech  5 лет назад

      You're welcome! I'm happy you liked it

  • @anugrah.singhal
    @anugrah.singhal 3 года назад

    Very good content 😊

  • @studio2038
    @studio2038 4 года назад +1

    nice explanation

  • @tejasdoond7614
    @tejasdoond7614 6 лет назад +1

    Awesome dude... Helped a lot

    • @DefogTech
      @DefogTech  6 лет назад

      Glad it helped. Thank you!

  • @kakashihatake4840
    @kakashihatake4840 6 лет назад +3

    Please do more such videos

  • @gurupadamgundala5142
    @gurupadamgundala5142 5 лет назад +4

    Awesome. Expected more videsos 👌👌👌

  • @kannadasans7564
    @kannadasans7564 4 года назад

    Could you make a samples of reactive programming followed by your aka Java fiber videos. For eg, How to use RxJava for the below categories of apps,
    1. Considering both frontend and backend
    2. Considering there is no frontend and it's purely backend app.
    Doing good job. Really great👍

  • @bluecomment6146
    @bluecomment6146 2 года назад

    Superb video

  • @ganeshpathak4804
    @ganeshpathak4804 5 лет назад +2

    Hi,
    I have one request if you could make a video on Performance improvement techniques. Not necessarily related to threading but in general.
    I am sure everyone would be benefited as you explain complex things in very simple way :)

    • @DefogTech
      @DefogTech  5 лет назад

      Sure, sounds like a good idea. Will add it to the list

  • @mahendrakhedhar6054
    @mahendrakhedhar6054 5 лет назад

    read write barrier means what sir please explain if we use volatile what happens to those barriers

  • @pradhumansingh1195
    @pradhumansingh1195 3 года назад

    Who the hell dislikes such a great videos??

  • @narendramanikanta7597
    @narendramanikanta7597 5 лет назад +1

    Awesome explanation mate. God bless you

  • @aniln4736
    @aniln4736 4 года назад

    In my case there is concurrent hashmap obj that holds configurations read from different server.
    Quartz scheduler will fetch configuration data for every 30 sec and update a new data (whole obj) to this concurrent hashmap..
    In this case ,in my opinion voltaile should be used to always get the updated obj to the reader threads but some quality checking tools raising it as bug
    So any suggestions during this scenario

  • @kamilwrobel4438
    @kamilwrobel4438 2 года назад

    So if two threads are runing in one core, there is no need to use volatile keyword because they share same cache?

  • @shilpaagrawal7126
    @shilpaagrawal7126 4 года назад

    Awesome video... Can u also make video on design patterns ...?

  • @BeatSyncBytes
    @BeatSyncBytes 3 года назад

    Explaination with L2 and L3 is so deep. How do you get so deep

  • @khushbuchoudhary5185
    @khushbuchoudhary5185 3 года назад

    Super video! I applauded for ₹40.00 👏

  • @user-cf6ts2sc5x
    @user-cf6ts2sc5x 3 месяца назад

    good job, man!

  • @suhaspartha2908
    @suhaspartha2908 3 года назад

    Superb!

  • @myvinbarboza3038
    @myvinbarboza3038 4 года назад

    Your the best man 😀

  • @uka0002
    @uka0002 4 года назад +1

    Great video

  • @RobinsonGames
    @RobinsonGames 4 года назад +1

    Really good explanation with a good visual display of those

  • @dinkarinjosh
    @dinkarinjosh 4 года назад

    can you please make a video on working of JVM and its architecture? btw good job.

  • @abhinavsrivastava1870
    @abhinavsrivastava1870 4 года назад

    Can Volatile keyword be used with HashMap in any where code snippet. If yes, how to do that?