Using volatile vs AtomicInteger in Java concurrency

  Рет қаралды 303,226

Defog Tech

Defog Tech

6 жыл бұрын

When to use volatile, and when to use Atomic counterparts like AtomicInteger? What are the advantages and use cases of each?
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...

Пікірлер: 316
@bhaaratsharma6023
@bhaaratsharma6023 3 жыл бұрын
Not saying for the sake of saying but after visiting a lot of other channels I always come back to your videos for anything related to multithreading. You are simply awesome.
@dig8195
@dig8195 3 жыл бұрын
Hey man. I know this is already a 2year old video but I would like to express my thanks for putting these videos and I really learned a lot. Anything related to threads and concurrency in Java have been very intimidating for me and I always thought it's not important as I'm doing well in my current role in the company I'm working with. However, I realized my career as a software engineer is in rot due to not taking risks and for not taking on challenges by exploring what is out there for me. I applied for Canva(spoiler: didn't got the job) and since then, I started watching your videos and practice coding related to java concurrency because it was advised on their role description. I'm still brokenhearted by the feedback that I didn't pass their first coding exam, hence, was not able to apply what I've learned from you. I'm still very thankful for what I've learned from your videos and made me more interested in this part of java. Keep on making videos. Thanks!
@freezefrancis
@freezefrancis 9 ай бұрын
+1 prepping for Canva here. Coincidentally found this video and this comment.
@rohithp9774
@rohithp9774 3 жыл бұрын
"The Best Content" for concurrency in java. Thanks much!
@yadavankit
@yadavankit Ай бұрын
such a simple quick explanation. I keep coming on this channel for multi-threading concepts every once in a while
@bhartisingh4895
@bhartisingh4895 3 жыл бұрын
Your videos are awesome .The lucid manner in which the concepts are explained is of the highest quality. Please continue making videos and never slow down.
@Kp96321
@Kp96321 5 жыл бұрын
Probably the most comprehensive explanation I've seen yet (recommend listening at 1.5x), thanks alot!
@swapnilankalkhope1896
@swapnilankalkhope1896 5 жыл бұрын
Clear and precise explanation...Best Ever!!! Plz Upload more core java concepts
@purnimadas3762
@purnimadas3762 5 жыл бұрын
Excellent, you have nailed it, you explained it so well, so clearly, to the point. Appreciate you effort. Thanks a lot for posting it.
@chernanq88
@chernanq88 Жыл бұрын
This is by far the best explanation of synchronization I ever seen, thanks for that!
@neeraj91mathur
@neeraj91mathur 2 жыл бұрын
This is one of the clearest explanations I got about volatile and Atomic on the internet. Well done.
@mukeshsinghdance7332
@mukeshsinghdance7332 4 жыл бұрын
After reading hundreds of resources finally I got the answer her. How to and where to use Volatile and Atomic variables.
@pandit-jee-bihar
@pandit-jee-bihar 4 жыл бұрын
This is the best that you can do in 7 minutes to explain these relatively confusing concept.
@vijayakumarvj
@vijayakumarvj 3 жыл бұрын
Perfect explanation!! I hope whoever watches this video, for sure they will get the idea of volatile and atomicInteger. Would you explain more about AtomicReference Class and its usage.
@mostinho7
@mostinho7 4 жыл бұрын
Done thanks 0:40 changing a variable in one thread will NOT reflect in the other thread. (Threads both have access to the variable, but each thread running on a different core the cpu has a local cache of the variable) 2:30 volatile solves visibility issue but doesn’t solve synchronization issues (when both threads are modifying the same variable, both could increment but the value is only +1 instead of +2) 4:50 solving synchronization with synchronized keyword 5:15 atomic variables provide atomic operations (incrementong happens as one operation instead of read then increment then write, where both threads could be running together) 6:30 which variables to make volatile and which values to make atomic
@nishanthk9100
@nishanthk9100 4 жыл бұрын
I wish there is an option to like all the videos in the playlist at once. Amazing explanation keep going please!
@appudeutsch8124
@appudeutsch8124 5 жыл бұрын
So glad to have run into this. Great clarity.
@viveksinghdroid
@viveksinghdroid 3 жыл бұрын
Making everyone understand small things is not a small thing. Kudos to your way of explanation :)
@rocky10317
@rocky10317 2 жыл бұрын
Best Explanation, I have searched for volatile for so long, but understand here. Thanks
@_dinesh
@_dinesh 2 жыл бұрын
One of the best explanations I have ever heard. Man you are simply awesome. Straight to the point and very clear!!!!!!! 👏👏👏👏 Keep up the great work! I'm subscribed!
@chaitanyawaikar382
@chaitanyawaikar382 Жыл бұрын
Clear and concise videos. Enjoyed every single minute of this video. The clarity with which the concept is being explained is simply unparalleled. Thank you !!!
@jasper5016
@jasper5016 Жыл бұрын
It could not be more simpler. Thanks a ton.
@hyperborean72
@hyperborean72 4 жыл бұрын
Finally I understood the concept - thank you immensely
@pkbkarpr
@pkbkarpr 3 жыл бұрын
Short and Sweet
@arunsundar3739
@arunsundar3739 4 жыл бұрын
all the essence about volatile, synchronized, atomic explained in simple effective way, beautiful :)
@hemalnakrani4419
@hemalnakrani4419 2 жыл бұрын
2 main concepts explained in 7 minutes ,hatsoff!!
@souravsuman1993
@souravsuman1993 5 жыл бұрын
Nice tutorial. It clears the concept of volatile and atomic integer
@ayushshukla1597
@ayushshukla1597 3 жыл бұрын
You're doing an amazing job. Thank you for all your efforts.
@rajpreetnayyar1011
@rajpreetnayyar1011 2 жыл бұрын
Amazing explanation! Tbh one of the best explanation of volatile on the internet!
@tarun4705
@tarun4705 3 ай бұрын
This playlist is a treasure
@amanueletana
@amanueletana 6 ай бұрын
you are amazing man. thank u. Indeed short and sweet.
@saumitrasaxena8470
@saumitrasaxena8470 2 жыл бұрын
very good explanation with very good example !!! I think I will never forget this concept now -Volatile/Synchronization and AtominInteger.
@NK-ju6ns
@NK-ju6ns 2 жыл бұрын
Whenever I wanted refresh my java concurrency knowledge, this is the place I come in.
@bhujangbhagas2475
@bhujangbhagas2475 2 жыл бұрын
It couldn't have been explained any better..thanks a lot.
@pratapjavasingh3239
@pratapjavasingh3239 3 жыл бұрын
I never seen this type of video how crystally explain each concept through out the example u have really gud command of mutithreading 👍🙏
@AKatyal90
@AKatyal90 11 ай бұрын
Very crisp and clear content! Thank you, thank you !!😊
@contactdi8426
@contactdi8426 2 жыл бұрын
Huge Salute/respect to you sir. I always first like the video before starting and then start watching.
@maheverse7223
@maheverse7223 2 жыл бұрын
such a crystal clear simple and short explanation.just waoo
@gauravjoshi6901
@gauravjoshi6901 3 жыл бұрын
i have 8 year exp and preparing for a major interview..all your videos are absolutely to the point. Cheers
@ManishKumar-qx1kh
@ManishKumar-qx1kh 4 жыл бұрын
I am late to this channel but i must say the explanations you give are awesome. Thanks for the hard work.
@jayeshborgaonkar9166
@jayeshborgaonkar9166 4 жыл бұрын
short and sweet to the point, clear explanation,
@MohitKumar-os3ir
@MohitKumar-os3ir 3 жыл бұрын
Every time I watch a video of you. Only one thought. This guy is a genius.
@MouraBee
@MouraBee Жыл бұрын
Fabulous explanation, I finally understood the AtomicInteger. Thanks!! ^^
@AliBenZarrouk
@AliBenZarrouk 5 жыл бұрын
Short & sweet :) Thanks !
@cslxxwilliam
@cslxxwilliam 3 жыл бұрын
Thanks for the clear explanation on Volatile!
@hareeshrajendran
@hareeshrajendran 7 ай бұрын
The best video about the keyword volatile!! Hands Down
@Max-zf5ot
@Max-zf5ot 4 жыл бұрын
Very succinct and to the point. Thank you for the great work.
@jeevan4337
@jeevan4337 5 жыл бұрын
Awesome explanation, clear voice, pronunciation, apt speech rate, no slow, no high. One question: What if all threads are running in parallel? Like parallel browsers? How can I make only one browser (thread) update the database?
@tarunmishra6641
@tarunmishra6641 3 жыл бұрын
Excellent explanation like always.. So articulate and to the point.. Cheers!!
@limmatthew3745
@limmatthew3745 5 жыл бұрын
well explained, Thank You
@satyasarma2458
@satyasarma2458 3 жыл бұрын
Great Explanation..! look forward to more technical query explanations.
@unikkkkkkk
@unikkkkkkk 3 жыл бұрын
The Best Playlist for Java Concurrency. Thanks.
@rujutasamant8881
@rujutasamant8881 3 жыл бұрын
Your explanation does clear all doubts
@VinayakMore0914
@VinayakMore0914 2 жыл бұрын
"Best content on Java Advance Topics and Interview Questions" , Please Keep doing more such videos on microservices and AWS.
@speedmishra13
@speedmishra13 5 жыл бұрын
Thank you. Very helpful! Keep up the good work!
@vijisdiary4902
@vijisdiary4902 5 жыл бұрын
I was surfing for a very long time to understand it better . Your video was the best i have ever seen .
@DefogTech
@DefogTech 5 жыл бұрын
Thank you! I'm happy it helped
@siddhaarth8843
@siddhaarth8843 5 жыл бұрын
Such an clear explanation ! Succcint and up to the point, before this no one really helped me understand the real implications of the volatile keyword, and many assumed volatile is the equivalent keyword of synchronized, for variables, but no, it is not !
@rajeevkandpal1880
@rajeevkandpal1880 3 жыл бұрын
Thanks for such wonderful videos.... you are the best in multithreading...
@Rahul-co2zj
@Rahul-co2zj 5 жыл бұрын
fantastic explanation !! keep it up brother....
@nikalldway1
@nikalldway1 3 жыл бұрын
Very simple and straight explanation good job
@hemantk611
@hemantk611 5 жыл бұрын
Very nice way to explain such a complex topic.Thanks a lot.
@shriramk0
@shriramk0 2 жыл бұрын
well done! brief and up to the point
@keshavrastogi5005
@keshavrastogi5005 3 жыл бұрын
Finally I am able to comprehend atomic integer and its use... Thanks a lot! :)
@pratapsingh-le2br
@pratapsingh-le2br 4 жыл бұрын
i've never seen any tutorial regarding the multithreading in youtube like u i don't have any word what i said here really mesmerizing wd speechless bdw i am subscribing ur channel please upload the video Collection and OOps Concept and Exception Handling wd internal in depth wd relate the what ever u explain the concept real time like Banking domain and E Commerce
@tsGarpfin1
@tsGarpfin1 4 жыл бұрын
Great and simple explanation, thank you.
@jeffGordon852
@jeffGordon852 4 жыл бұрын
That was a great video, keep up the good work.
@isaurabh2001
@isaurabh2001 4 жыл бұрын
Very good. Teaching is an art & you definitely know it.
@MyAmitbisht
@MyAmitbisht 3 жыл бұрын
Really nice way of explaining the concepts. Thanks
@subirsaha4031
@subirsaha4031 4 жыл бұрын
You have explained the topic very nicely. Thanks. 👍
@ibrahimshaikh3642
@ibrahimshaikh3642 3 жыл бұрын
Very useful info ,Waiting for u r new videos
@singsarav
@singsarav 4 жыл бұрын
Excellent briefing. Keep it up.
@diptidesai7399
@diptidesai7399 5 жыл бұрын
Superb 👌 you explained it truely short n sweet way. Good good
@mahendharkhedhar7887
@mahendharkhedhar7887 5 жыл бұрын
really short and sweet,i don't have much clarity about volatile keyword i have searched many sites no one clearly explained like you really pictures,explanation,animations really very understandable way that for providing this vedio sir,expected more content like this sir.Thank you sirrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.................................................
@DefogTech
@DefogTech 5 жыл бұрын
You are very welcome. I'm happy it helped!
@jericho7989
@jericho7989 3 жыл бұрын
You are really good on explaining complicated things.. I hope you make more video in java and spring, spring boot
@manojsingh-xm5ph
@manojsingh-xm5ph 5 жыл бұрын
Awesome !!!. Very nicely explation of each and every topics of channel uploaded videos.Want to see more and more topics on java concurrent api..Keep it up.
@DefogTech
@DefogTech 5 жыл бұрын
Thank you for the kind words and your motivation sir!
@architadas5077
@architadas5077 4 жыл бұрын
Very well explained. Thank you.
@shubhadamanchewar9228
@shubhadamanchewar9228 4 жыл бұрын
Very nicely explained. Thank you
@1minuteconcepts
@1minuteconcepts 2 жыл бұрын
Great content, v easy to grasp, thanks for making these videos!!
@prathamkrishna3751
@prathamkrishna3751 2 жыл бұрын
this was a quite insightful video, loved how it is explained:)
@yogeshchaudhary621
@yogeshchaudhary621 Жыл бұрын
Excellent explanation!
@TheGuroguro12
@TheGuroguro12 5 жыл бұрын
Thank you very much for shearing the knowledge.
@vijaykumar-yb8yt
@vijaykumar-yb8yt 5 жыл бұрын
One of the best explanation...very nice keep doing 👍
@NilanshuSharma1
@NilanshuSharma1 5 жыл бұрын
It might also help to share that volatile is enough if there is just one thread writing and multiple threads reading a variable. However, if more than one thread write, then we've those synchronize those.
@lone_warrior3672
@lone_warrior3672 3 жыл бұрын
Nicely Explained!
@MagnumRocha87
@MagnumRocha87 2 жыл бұрын
Very clear and good explanation of the topic, congrats 👏
@thedevtutorials
@thedevtutorials 2 ай бұрын
top notch explaination !
@Lucky-uz3je
@Lucky-uz3je 5 жыл бұрын
You have got one more subscriber.... Awesome explanation :)
@DefogTech
@DefogTech 5 жыл бұрын
Thank you!
@vamshikrishna8143
@vamshikrishna8143 5 жыл бұрын
count me in as well
@vaseefcool
@vaseefcool 4 жыл бұрын
Metoo
@Lucky-uz3je
@Lucky-uz3je 4 жыл бұрын
30 likes means, Defog Tech got 30 more subscriber. Awesome. You deserve more than that. Keep it up.😊👍
@Lucky-uz3je
@Lucky-uz3je 3 жыл бұрын
Thanks for the 💓.... But I have a complain from you. We, your subscribers, eagerly waits for your videos but it seems you are busy somewhere else. Please do your knowledge spread to us....😃 Lots of love. Keep it up.
@kirtim1930
@kirtim1930 3 жыл бұрын
nicely explained! thanks!
@grayyeung757
@grayyeung757 Жыл бұрын
Very useful illustration
@swagatpatra2139
@swagatpatra2139 3 жыл бұрын
Very good and clear explanation, thanks.
@andy6962
@andy6962 3 жыл бұрын
very well explained, liked
@balanepalaiyathane9714
@balanepalaiyathane9714 Жыл бұрын
Thank you very nice GOD BLESS YOU your service is really great
@rohitnegi5197
@rohitnegi5197 2 жыл бұрын
Thanks a lot sir. Great learning
@praagar
@praagar 3 жыл бұрын
Nice Info, but mentioning on Compare and Swap (CAS) for Atomic operation would help your user to understand more and how optimistic locking works.
@samzuhalsetiawan5218
@samzuhalsetiawan5218 2 жыл бұрын
Easy to understand, thank you very much, greeting from Indonesia
@yoshitamahajan353
@yoshitamahajan353 3 жыл бұрын
Thank u so much best explanation!
@shubhammahindru3563
@shubhammahindru3563 2 жыл бұрын
The overall content is perfect and to the point but request you if you can add a bit of thread creation and synchronization with thread in older fashion like efficient usage of notify and wait, it will help I am sure a bigger audience
@gurudatt-shahane
@gurudatt-shahane Жыл бұрын
Thank you very much for making this video ❤
@siddharthkumarverma1207
@siddharthkumarverma1207 4 жыл бұрын
Smartly explained...
@niewinskipiotr1993
@niewinskipiotr1993 2 жыл бұрын
Small comment, but quite useful - You don't have to mix volatile with synchronized, because synchronized already has a memory barrier that guarantees visibility of changes that were made within synchronized blocks of the same lock. "On the same lock" is the keyword here
@shubhamtandon5191
@shubhamtandon5191 3 күн бұрын
Very nice, thanks bro
ThreadLocal in Java
10:59
Defog Tech
Рет қаралды 179 М.
Introduction to CompletableFuture in Java 8
19:34
Defog Tech
Рет қаралды 318 М.
小路飞姐姐居然让路飞小路飞都消失了#海贼王  #路飞
00:47
路飞与唐舞桐
Рет қаралды 94 МЛН
КАК СПРЯТАТЬ КОНФЕТЫ
00:59
123 GO! Shorts Russian
Рет қаралды 2,8 МЛН
How many pencils can hold me up?
00:40
A4
Рет қаралды 17 МЛН
Java Concurrecy: Volatile vs Atomic - Java Programming
10:50
Will Tollefson
Рет қаралды 1,5 М.
How HashMap works in Java? With Animation!! whats new in java8 tutorial
15:29
Ranjith ramachandran
Рет қаралды 1 МЛН
Java Memory Model in 10 minutes
10:55
Defog Tech
Рет қаралды 253 М.
Concurrency vs Parallelism
8:23
Defog Tech
Рет қаралды 239 М.
Java BlockingQueue
17:48
Jakob Jenkov
Рет қаралды 37 М.
What role has the VOLATILE keyword in Java?
9:08
Visual Computer Science
Рет қаралды 17 М.
Java Asynchronous Programming
16:07
Defog Tech
Рет қаралды 144 М.
как спасти усилитель?
0:35
KS Customs
Рет қаралды 481 М.
Карточка Зарядка 📱 ( @ArshSoni )
0:23
EpicShortsRussia
Рет қаралды 223 М.