goroutine

我理解的goroutine就是一个和其他goroutine并发运行的函数.

goroutine 和线程的区别

参考: http://blog.nindalf.com/how-goroutines-work/

启动一个goroutine

1
2
3
4
5
6
7
8
9
10
11
12
13
package main

import (
"fmt"
"time"
)

func main() {
go func() {
fmt.Println("Hello, Goroutine!")
}()
time.Sleep(1 * time.Second)
}