调整示例程序格式

将程序和输出放在某个代码片段中,应该有格式的统一。

另一个方式是将程序输出放在一个单独的代码片段中,类似 https://gobyexample.com/hello-world
This commit is contained in:
Jiaying Ren
2014-01-23 21:10:57 +08:00
parent 50e677514c
commit 7bd28a6fd7

View File

@@ -31,16 +31,16 @@ goroutine是通过Go的runtime管理的一个线程管理器。goroutine通过`g
say("hello") //当前Goroutines执行
}
输出:
hello
world
hello
world
hello
world
hello
world
hello
// 以上程序执行后将输出:
// hello
// world
// hello
// world
// hello
// world
// hello
// world
// hello
我们可以看到go关键字很方便的就实现了并发编程。
上面的多个goroutine运行在同一个进程里面共享内存数据不过设计上我们要遵循不要通过共享来通信而要通过通信来共享。