```go
package main
import (
"fmt"
"time"
)
func DoThing(){
for{
fmt.Println("DoThine", time.Now())
time.Sleep(1*1e9)
}
}
func main(){
for i:=0; i<100000; i++{
go DoThing()
}
for{
time.Sleep(1*1e9)
}
}
```
更多评论
很简单,起 10w 个协程,打印一行文字,环境:ubuntu14.04
启动方式:
1 ./bin >> log,这种方式运行没有问题
2 ./bin 直接输出到屏幕,不出10秒程序崩溃
提示如下:
goroutine 1865 [sleep]:
time.Sleep(0x3b9aca00)
/usr/lib/go-1.6/src/runtime/time.go:59 +0xf9
main.DoThing()
/home/jinqiao/e/work/go/test/one.go:11 +0x181
created by main.main
/home/jinqiao/e/work/go/test/one.go:19 +0x3a
#2