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