box-o-sand/gotime/src/meatballhat.com/gotour-artifacts/buffered-channels/main.go

30 lines
443 B
Go
Raw Normal View History

2012-11-07 05:16:13 +00:00
package main
import (
"fmt"
"time"
)
2012-11-07 05:16:13 +00:00
func main() {
c := make(chan int, 2)
q := make(chan bool)
go func(c chan int) {
for i := range c {
fmt.Println("\t", i, "<- popped")
time.Sleep(300 * time.Millisecond)
}
}(c)
go func(c chan int) {
i := 0
for {
c <- i
fmt.Println("pushed ->", i)
i += 1
}
}(c)
<-q
2012-11-07 05:16:13 +00:00
}