Lua-- 协程 Lua-- 协程
发布时间
阅读量:
阅读量
print("******* Coroutine *******")
-- 协程:协同程序
-- print("******* 协程的创建 *******")
-- 常用方式:coroutine.create() —— 返回线程对象
fun = function ()
print("123")
end
co = coroutine.create(fun)
--[[
等效于
co = coroutine.create(function ()
print("123")
end)
]]
-- 协程的本质是一个线程对象
print(co)
print(type(co))
-- coroutine.wrap(f) —— 返回函数对象
co2 = coroutine.wrap(fun)
print(co2)
print(type(co2))
-- print("******* 协程的运行 *******")
-- 第一种方式,对应的 是通过 creat
全部评论 (0)
还没有任何评论哟~
