1、主线程等待多个协程执行完毕后,再执行下面的程序。golang提供了一个很好用的工具。 sync.WaitGroup下面是个简单的例子。
执行结果:
2、主线程主动去结束已经启动了的多个协程。执行结果是: