From ed8cae764cb01ddcb955cd1cd788448ad6430fc9 Mon Sep 17 00:00:00 2001 From: Jiaying Ren Date: Thu, 23 Jan 2014 21:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=A4=BA=E4=BE=8B=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将程序和输出放在某个代码片段中,应该有格式的统一。 另一个方式是将程序输出放在一个单独的代码片段中,类似 https://gobyexample.com/hello-world --- ebook/02.7.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ebook/02.7.md b/ebook/02.7.md index eafaf9f8..d2919a2d 100644 --- a/ebook/02.7.md +++ b/ebook/02.7.md @@ -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运行在同一个进程里面,共享内存数据,不过设计上我们要遵循:不要通过共享来通信,而要通过通信来共享。