Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- import "sync"
- import "time"
- func main() {
- fmt.Println("Hello")
- var mu sync.Mutex
- cond := sync.NewCond(&mu)
- mu.Lock()
- go func() {
- // mu.Lock()
- cond.Broadcast()
- // mu.Unlock()
- }()
- fmt.Println("Sleeping...")
- time.Sleep(1000 * time.Millisecond)
- fmt.Println("...Slept")
- cond.Wait()
- mu.Unlock()
- }
Advertisement
Add Comment
Please, Sign In to add comment