Advertisement
Guest User

Untitled

a guest
May 28th, 2017
57
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 (
  4. "fmt" // output formatter
  5. "runtime"
  6. )
  7.  
  8. func runner(id int, ch chan string){
  9. for i := 0; i < 50; i++{
  10. ch <- fmt.Sprint(id) + " " + fmt.Sprint(i) + "\n"
  11. }
  12. }
  13.  
  14. func main() {
  15. runtime.GOMAXPROCS(11)
  16. ch := make(chan string)
  17. go runner(1, ch)
  18. go runner(2, ch)
  19. go runner(3, ch)
  20. go runner(4, ch)
  21. go runner(5, ch)
  22. for i := 0; i < 250 ; i++ {
  23. fmt.Printf(<- ch)
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement