标签:cti status yield -- 协同 状态 function resume for
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))
标签:cti status yield -- 协同 状态 function resume for
原文地址:http://www.cnblogs.com/ningyongbin/p/6005748.html