Skip to content

Instantly share code, notes, and snippets.

@jcelliott
Created September 8, 2013 21:25
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 jcelliott/6488539 to your computer and use it in GitHub Desktop.
Save jcelliott/6488539 to your computer and use it in GitHub Desktop.
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