Skip to content

Instantly share code, notes, and snippets.

@emepyc
Created March 16, 2012 13:23
Show Gist options
  • Save emepyc/2050047 to your computer and use it in GitHub Desktop.
Save emepyc/2050047 to your computer and use it in GitHub Desktop.
package main
import (
"time"
"runtime"
"fmt"
)
var (
qstate = make(chan int, 8)
)
func init() {
runtime.GOMAXPROCS(2)
}
func main() {
go runRead()
for s := range qstate {
fmt.Println(s)
}
}
func runRead() {
count := 0
for {
count ++
if count == 10 {
fmt.Println("stopRead")
qstate <- 1 //
close(qstate)
} else {
time.After(100000000)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment