function SayHey(mag) for i = 1 , 3 do print(mag) coroutine.yield() end end --创建携程(协同) coFunc= coroutine.create(SayHey) --查看携程状态 print(coroutine.status(coFunc)) --开启携程 coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc))coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc)) coroutine.resume(coFunc,"运行携程") print(coroutine.status(coFunc))
|
请发表评论