标签:++ run local import highlight ros 协程 i++ func
package main import ( "time" "fmt" "runtime" ) func test() { for i:=0;i<10;i++{ time.Sleep(time.Microsecond *100) fmt.Print(i) } fmt.Println("--------") } func main() { runtime.GOMAXPROCS(2) go test() go test() time.Sleep(time.Second * 5) print(runtime.NumCPU()) // 获取电脑cpu数量 }
结果
GOROOT=/usr/local/go #gosetup
GOPATH=/www/gopath #gosetup
/usr/local/go/bin/go build -i -o /private/var/folders/fc/4txmmczj6q92p6058h3w7t_80000gn/T/___go_build_main_go__2_ /www/go/learn/main.go #gosetup
/private/var/folders/fc/4txmmczj6q92p6058h3w7t_80000gn/T/___go_build_main_go__2_ #gosetup
00112233445566778899--------
--------
8
Process finished with exit code 0
标签:++ run local import highlight ros 协程 i++ func
原文地址:https://www.cnblogs.com/php-linux/p/13059019.html