print("**********协程的挂起************") functionFun2() local i = 1 whiletruedo print(i) -- 协程的挂起函数 coroutine.yield("协程挂起: " .. i) i = i + 1 end end
local co3 = coroutine.create(Fun2) local isOK, tempI = coroutine.resume(co3) print(isOK, tempI) local isOK, tempI = coroutine.resume(co3) print(isOK, tempI) local isOK, tempI = coroutine.resume(co3) print(isOK, tempI)
print("**********协程的状态************") functionFun() print(123) end local co = coroutine.create(Fun)
functionFun2() local i = 1 whiletruedo print(i) i = i + 1 print(coroutine.status(co3)) coroutine.yield("协程挂起: " .. i) end end co3 = coroutine.create(Fun2)
print("**********协程的状态************") functionFun() print(123) print(coroutine.running()) end local co = coroutine.create(Fun)
functionFun2() local i = 1 whiletruedo print(i) i = i + 1 print(coroutine.running()) coroutine.yield("协程挂起: " .. i) end end co3 = coroutine.create(Fun2)