What Happens If We Forget to Unlock a Mutex?
Let’s dive into the consequences of failing to unlock a mutex.
We'll cover the following
Forgetting to unlock a sync.Mutex
mutex
Forgetting to unlock a sync.Mutex
mutex creates a panic situation even in the simplest kind of a program. The same applies to the sync.RWMutex
mutex.
Coding example
Let’s now see a code example to understand this unpleasant situation a lot better—this is part of forgetMutex.go
.
Get hands-on with 1200+ tech skills courses.