Created
March 2, 2015 15:01
-
-
Save iporsut/c161e3d75b60c05af927 to your computer and use it in GitHub Desktop.
Goroutine SecondCounter Channel Sync
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 | |
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