Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
调整示例程序格式
将程序和输出放在某个代码片段中,应该有格式的统一。

另一个方式是将程序输出放在一个单独的代码片段中,类似 https://gobyexample.com/hello-world
  • Loading branch information
mikulely committed Jan 23, 2014
commit ed8cae764cb01ddcb955cd1cd788448ad6430fc9
20 changes: 10 additions & 10 deletions ebook/02.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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运行在同一个进程里面,共享内存数据,不过设计上我们要遵循:不要通过共享来通信,而要通过通信来共享。
Expand Down