Advertisement
Guest User

Untitled

a guest
May 29th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6. ch := make(chan int)
  7.  
  8. for i := 0; i < 5; i++ {
  9. go func() {
  10. ch <- i
  11. }()
  12. }
  13.  
  14. fmt.Println(<-ch) // 5
  15. fmt.Println(<-ch) // 5
  16. fmt.Println(<-ch) // 5
  17. fmt.Println(<-ch) // 5
  18. fmt.Println(<-ch) // 5
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement