Guest User

Untitled

a guest
May 9th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4. import "sync"
  5. import "time"
  6.  
  7. func main() {
  8. fmt.Println("Hello")
  9.  
  10. var mu sync.Mutex
  11. cond := sync.NewCond(&mu)
  12.  
  13. mu.Lock()
  14.  
  15. go func() {
  16. // mu.Lock()
  17. cond.Broadcast()
  18. // mu.Unlock()
  19. }()
  20.  
  21. fmt.Println("Sleeping...")
  22. time.Sleep(1000 * time.Millisecond)
  23. fmt.Println("...Slept")
  24.  
  25. cond.Wait()
  26. mu.Unlock()
  27. }
Advertisement
Add Comment
Please, Sign In to add comment