Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Created January 29, 2014 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszkorecki/8688614 to your computer and use it in GitHub Desktop.
Save lukaszkorecki/8688614 to your computer and use it in GitHub Desktop.
package main
import (
"time"
"fmt"
)
func main() {
fmt.Print("hello!")
stat := make(chan int , 20)
for i:=0 ; i < 20 ; i++ {
go func(i int, c chan int ) {
fmt.Printf("Hello from %s\n", i)
time.Sleep( 2 * time.Second)
c <- i
}(i, stat)
}
for f := range stat {
fmt.Printf("go a hit %s\n", f)
if f >= 19 {
close(stat)
}
}
fmt.Print(" --- done --- \n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment