Java Happens Before Guarantee - Java Memory Model - Part 2

preview_player
Показать описание
The Java Happens Before Guarantee is a set of rules that restrict instruction reordering to make sure that instruction reordering does not break the Java visibility guarantees. Breaking the visibility guarantees (of data shared between threads) would make thread communication in Java much less reliable, and thus harder to get right. The Java Happens Before Guarantee counters that.

Chapters:
0:00 Java Happens Before Guarantee - Introduction
0:34 Instruction reordering explained
3:42 Instruction reordering may affect visibility of changes to objects shared between threads
7:04 The visibility guarantee of volatile variables
11:18 Instruction reordering may break the volatile visibility guarantee
14:10 Volatile happens before guarantee
17:08 Synchronized visibility guarantee
20:09 Instruction reorderingmay break the synchronized visibility guarantee
22:45 Synchronized happens before guarantee
25:06 Further notes

Java Memory Model - JSR 133

Here is a textual version of this Java Happens Before Guarantee tutorial:

The Java Happens Before Guarantee is part of the Java Memory Model. I have an introduction to the Java Memory Model (link below) which content I assume you are reasonably familiar with (thread stacks and the heap) before watching this video.

Java Concurrency video playlist:

Java Concurrency textual tutorials:
Рекомендации по теме
Комментарии
Автор

Is there a mistake at 9:57? Should it say the this.framesTakenCount is being read from main memory, not this.framesStoredCount (which is what the diagram says). Is that correct or am I misunderstanding?

joemason
Автор

I no longer need to try Heroin - I'm addicted to your tutorials!!!

michaelhughes
Автор

Your videos on multi-threading are golden for many beginners, many thanks for the clear explanations and your approach to teaching!

simoo
Автор

Sir, you are a genius at this, internet is filled with just basics of threading but this is exactly what I was looking for, Thank you a lot for the amazing explanation.

adityavats
Автор

God of Concurency..i have bene flowing you since my 2014 when you used to write blog post only...by going through your post i attend interview like a LION when they ask mutithreading a Lot form 10+ yrs exp guy from BLR, India.

shubhamagarwal
Автор

This is the greatest Java tutorial I've ever seen, very clear and goes over each point slowly and carefully, thanks so much I really appreciate it,

jordanweir
Автор

Did not know about these guarantees for `volatile`. Great playlist with a smooth explanation! Thank you, Jakob!

kirillgavrilov
Автор

Excellent explanation! Had been looking for a simple, lucid explanation on this concept but couldn't find anything as good as this. Thanks a ton!

shilpapatnaik
Автор

it's the treasure to find such the clearest explanation :))

kafychannel
Автор

Very clear way of explanation! Thanks a lot, Jakob!

flamencoag
Автор

Ok!! I need to wrap my head around these words of wisdom!! Why my Java Teacher never taught me all these in classes? So well explained. Watching a video like this inspires me to realise about the connection between the every piece of code we write and the hardware underneath!!

vikashjhaVJEY
Автор

I'm really impressed with that great explanation and the way you simplify things with the graphs and code samples!
Thank you for putting all that effort!

BTW IF You Didn't Have a Profile Picture I Would Have thought This is LORD BEALISH speaking😂

samahdaou
Автор

This is great! So many new things to learn here! Thanks for your effort for this playlist!

himanshusingh
Автор

Best video over internet on Multithreading I ever found. Thank you for sharing such videos❤️.

chiranjibdash
Автор

Very well explained Jakob!! Thanks for making this video

manoj.tyg
Автор

That Happens Before to volatile variable thing was something new to me!!! loved your videos because of compactness and information..

AdventureTrekRide
Автор

you have made me a fan boy Jakob. Thankyou for this precise explanation.

ashutoshkedar
Автор

great, will have to watch this twice to fully get this but this is still gold

SoeaOu
Автор

Thank you. Very sequential and precise explanation.

ffatheranderson
Автор

00:02 Java Happens Before Guarantee and Instruction Restriction
03:12 Instruction reordering can affect multi-threaded applications
06:41 Java volatile keyword ensures visibility of changes made by one thread to another
10:09 Volatile variables need to be flushed to main memory
13:19 Instruction reordering can break visibility guarantees of volatile variables
16:34 Java has challenges with instruction reordering and visibility
19:47 Instruction reordering around synchronized blocks may break visibility guarantees.
23:01 Java happens before guarantees ensure correct communication between threads.

Crafted by Merlin AI.

damilola_adegunwa