Исходники и презентации
This commit is contained in:
16
lessons/sync_primitives/lock_granularity/main.go
Normal file
16
lessons/sync_primitives/lock_granularity/main.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var mutex sync.Mutex
|
||||
var cache map[string]string
|
||||
|
||||
func doSomething() {
|
||||
mutex.Lock()
|
||||
item := cache["key"]
|
||||
fmt.Println(item)
|
||||
mutex.Unlock()
|
||||
}
|
||||
Reference in New Issue
Block a user