mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-20 07:02:53 +02:00
initial import
This commit is contained in:
23
golang-language-samples/defer-lock/defer.go
Normal file
23
golang-language-samples/defer-lock/defer.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var lock sync.Mutex
|
||||
|
||||
func wasWichtiges() {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
//auf ressourcen zugreifen
|
||||
fmt.Println("Arbeit an gesperrter Ressource")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
wasWichtiges()
|
||||
lock.Lock()
|
||||
fmt.Println("am Ende")
|
||||
|
||||
}
|
Reference in New Issue
Block a user