Created
September 8, 2013 21:25
-
-
Save jcelliott/6488539 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
func work(id int, done chan int) { | |
println("processing top secret document:", id) | |
done <- id | |
} | |
func main() { | |
done := make(chan int, 5) | |
for i := 0; i < 5; i++ { | |
go work(i, done) | |
} | |
for i := 0; i < 5; i++ { | |
id := <-done | |
println("finished processing document:", id) | |
} | |
println("finished processing all documents") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment