Java Synchronized - The synchronized keyword in Java and Java synchronized blocks and methods

preview_player
Показать описание
Java synchronized blocks are either methods or blocks within methods which are synchronized. Synchronized blocks help solve concurrency problems like race conditions, data visibility, instruction reordering etc.

A Java synchronized block is synchronized on a specific "monitor object". Only one thread can enter any synchronized block synchronized on the same monitor object. Multiple synchronized blocks can be synchronized on a shared monitor object.

Chapters
0:00 Java synchronized - introduction
0:10 Java synchronized keyword
0:15 Synchronized instance methods
0:55 Synchronized blocks inside instance methods
1:36 Synchronized block monitor objects
6:15 Example of threads calling synchronized instance methods on a shared object
8:59 Synchronized static methods
11:21 Using both synchronized static and instance methods
13:44 Using different monitor objects for synchronized blocks within same class
15:25 Sharing monitor objects across different class instances (objects)
16:23 Monitor objects cannot be null
16:50 Example of sharing monitor objects across objects
20:58 Don't use String constant objects as monitor objects
22:13 Java synchronized blocks inside Java Lambda Expressions
25:34 Java synchronized block reentrance rules
27:41 Java synchronized block data change visibility guarantee
33:14 Java synchronized block visibility example
36:00 Java synchronized block happens before guarantee
40:48 Java syncronized block limitations
42:42 Java synchronized block performance overhead
43:56 Java syncrhronized blocks in clustered setups

Java Memory Model - JSR 133

Java volatile tutorial - textual / video:

Java Concurrency & Multithreading Playlist

Java Memory Model

Java Happens Before Guarantee

Java Lambda Expressions
Рекомендации по теме
Комментарии
Автор

Not a single video on YouTube matches this level of clarity and extensiveness about multithreading. Hats off to you.👌

kmsandeep
Автор

This content is gold. After almost 8 years, I keep on knowing things that I did not know before, not just this particular video but the whole series. Thank you, Jacob.

raj_kundalia
Автор

I am never seen tutorials with such clear explanation. Thank you Jakob.

fuadgafarov
Автор

A few years back, one of my friends suggested your tutorial for angularjs. It was easy to understand tutorial, compared to a lot of tutorials I went through. I searched for you and found this playlist of java multithreading, which is equally good. Great and very useful content. Thanks for sharing it. You deserve a lot more views and subscribers.

RaghuVN
Автор

I thought "Let me see some explanation so I can understand a little bit more about Sync" and then this video explains perfectly everything I need to know, thank you man!

marcusrigonati
Автор

I have to watch these videos at least twice because the content is too complex for my head. Thank you very much for making this matter clearer and easier to understand. This motivates me not to give up on this subject and keep learning.

OKelvinClark
Автор

I think after all these years working with java, this is the first time I have understood the synchronization. Many thanks.
I wish you also had videos about nio and io. It’s just easier when you explain them.

shilankalhor
Автор

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
Автор

Hi Jakob
I must say you and your tutorials are amazing.
Most grateful for explaining with such clarity.
For the first time, I understood synchronization in JAVA clearly.

swagatikachoudhury
Автор

The way you explain and takes deep dive, makes you to stand out from others ..amazing stuff.. much gratitude

stylishsannigrahi
Автор

These are the best tutorials I have ever seen on YouTube, ever, for anything. I rarely comment but I have to thank you. Keep up the good work and I'm positive you'll go far.

calumjb
Автор

the best explanation of java multithreading i've ever seen

druzzyaka
Автор

Thank you, Jakob! You're awesome. I was having difficulty understanding the those mutlithreading concepts while preparing for big-n interviews. Your videos and blogs help tremdously!

zhenlinjin
Автор

Thanks Jakob. I used to be a follower of your site a long time ago. Luckily I have found your video on youtube when I wanted to revisit my skills on threads. Very nice explanation with different examples. Thanks a lot for your efforts in providing quality content.

LOKeshrangineni
Автор

This Multithreading playlist is something invaluable! Hats off to you Jakob :)

viranchpatel
Автор

Wow, thanks so much for this video. I just started the topic multi-threading and when I got the first infos about it, so many questions were left open. Your tutorial made many things a lot clearer and I certainly will go on watching more of your videos for details on other aspects like the Happens Before Guarantee. It's so great, that there are videos/video collections like this on youtube which cover the topics with some deepness.

simongupta
Автор

I like your tutorials because you cut to the chase and describe everything clearly and with minimum bs.

Jaraqqeh
Автор

Awesome Tutorials on Concurrency... I was going through the Udemy Java course but now I am only watching your videos... Love from India...

shirshendudebroy
Автор

If i need to learn something in Java, First thing that comes to mind is your blogs and YT channel, Amazing content

abdurrehman
Автор

Dude, i refer to your java portal quite often! Didnt know you have youtube channel. Instant subscribe

anothermouth