2021
03-23
03-23
Golang 并发以及通道的使用方式
Golang最擅长的就是并发编程,使用Golang可以很方便的进行并发编程。先看一段普通的代码packagemainimport("fmt""time")funcFoo(iint){fmt.Printf("%dwillsleep\n",i)time.Sleep(5*time.Second)fmt.Printf("%dwakeup\n",i)}funcmain(){fori:=0;i<5;i++{Foo(i)}}输出为0willsleep0wakeup1willsleep1wakeup2willsleep2wakeup3willsleep3wakeup4willsleep4wakeup大概要执行25...
继续阅读 >