2021
06-07
06-07
golang coroutine 的等待与死锁用法
直接上代码:1.第一种情况如果没有select{},main主线程不会等待coroutine运行,导致coroutine得不到机会运行。Youarerequestingeventualscheduling(usingthetwogostatements)oftwogoroutinesandthenyouexitmainwithoutgivingtheschedulerachancetodoanything.有了select,程序正常运行。packagemainimport("fmt""time")funcmain(){gofunc1()gofunc2()select{}}funcfunc1(){...
继续阅读 >