1 Star 0 Fork 0

wukai / GoStudy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
goroutine.go 376 Bytes
一键复制 编辑 原始数据 按行查看 历史
君町love 提交于 2019-01-15 12:04 . Package change
package concurrent
import (
"fmt"
"runtime"
)
// Go语言的多线程术语是 goroutine 相当于java的Thread,但是与Thread有本质区别
func say(str string) {
for i := 0; i < 5; i++ {
runtime.Gosched()
fmt.Println("Hello ", i, " : ", str)
}
}
func GoRoutine() {
go say("world") // 另起一个goroutine执行
say("Go") // 在main goroutine执行
}
1
https://gitee.com/thinkerwolf/GoStudy.git
git@gitee.com:thinkerwolf/GoStudy.git
thinkerwolf
GoStudy
GoStudy
d5cdf10e6f5f

搜索帮助

53164aa7 5694891 3bd8fe86 5694891