10.1.goroutine
goroutine的使用
//learn_go/main.go
package main
import (
"fmt"
"time"
)
func demo(count int) {
for i :=1; i < 10; i++{
fmt.println(count,":",i)
}
}
func main() {
for i ...
waitgroup
概念
go标准库提供了waitgroup原语, 可以用它来等待一批 goroutine 结束
底层数据结构
// a waitgroup must not be copied after first use.
type waitgroup struct {
nocopy nocopy
state1 [3]...