1. Mutexes in Go
func protected(){
mu.Lock()
defer mu.Unlock()
// the rest of the function is protected
// any other calls to `mu.Lock()` will block
}Maps Are Not Thread-Safe
Assignment
What is a Mutex? (Real-World Analogy)
1
2
3
4
Why Do We Need Mutexes in Code?
Your Assignment Solution
Key Concepts Explained
Why defer mu.Unlock()?
defer mu.Unlock()?Why protect val() even though it only reads?
val() even though it only reads?