Advanced Golang: Deadlocks Explained

preview_player
Показать описание
Deadlocks in Go usually occur because of improper use of a mutex. I'll explain in the simplest terms what causes a deadlock and how to fix it.

While I use Golang for the code examples, the concepts apply to all languages with concurrency/multithreading.
Рекомендации по теме
Комментарии
Автор

encountered a prod issue today. Someone asked me about deadlock, and I don't think I understood the concept really well. Here I am :D thanks Ryan. just what I needed.

linuxmonkey
Автор

For Has func you can use RLock (Lock for read), it's can help for avoid deadlock

vitali
Автор

Thank you for your content, it's awesome, Bro! Very chill, informative and straight to the point!

uwontlikeit
Автор

Love the examples, Thanks and subscribed!

to-nl
Автор

Great video.I'm waiting new video

HoaNguyen-dnbz
Автор

since the has function is only reading just add a read only mutex to avoid having duplicate code. sync.RWMutex will avoid repetition

TonoNamnum
Автор

what if two goroutines call the Has function, one after the other, should it deadlock because the first goroutine locks then the other locks as well without waiting for unlock just like the first example?

guiguat
Автор

Hi Ryan!
I use programming for a hobby projects, but i have a question: placing a mutex before "if" was done only to show an exampe of dead lock or it`s standart practice for programming an actual applications?

azzzza