Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created March 2, 2015 15:01
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 iporsut/c161e3d75b60c05af927 to your computer and use it in GitHub Desktop.
Save iporsut/c161e3d75b60c05af927 to your computer and use it in GitHub Desktop.
Goroutine SecondCounter Channel Sync
package main
import (
"fmt"
"time"
)
var done chan bool = make(chan bool)
func SecondCounter() {
for i := 1; i <= 20; i++ {
time.Sleep(1 * time.Second)
fmt.Println(i)
}
done <- true
}
func main() {
go SecondCounter()
<-done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment