Go by Example - Goroutines
Go by Example
Go is an open source programming language designed for building simple, fast, and reliable software.
Go by Example is a hands-on introduction to Go using annotated example programs. Check out the first example or browse the full list below.
Go by Example: Goroutines
golang中的goroutine是一个比线程还要轻量的调度单位。
1 | package main |
1 | // 从输出的结果,匿名函数的输出插入在第一个goroutine的输出中,可看出两个函数调用是在独立的goroutine中并行执行 |