Created
January 29, 2014 14:04
-
-
Save lukaszkorecki/8688614 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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