Skip to content

Commit

Permalink
Update 2019-01-20-来-控制一下goroutine的并发数量.md
Browse files Browse the repository at this point in the history
  • Loading branch information
eddycjy authored Jan 22, 2019
1 parent 0256580 commit 6f999b0
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func main() {
userCount := 10
ch := make(chan bool, 2)
for i := 0; i < userCount; i++ {
wg.Add(1)
go Read(ch, i)
}
Expand All @@ -185,7 +186,6 @@ func main() {
func Read(ch chan bool, i int) {
defer wg.Done()
wg.Add(1)
ch <- true
fmt.Printf("go func: %d, time: %d\n", i, time.Now().Unix())
Expand Down

0 comments on commit 6f999b0

Please sign in to comment.