local timer = require ('timer')local function co3()print("coroutine3 start",os.clock())timer.sleep(5.5)print("coroutine3 5.5 second later",os.clock())print("coroutine3 end")end--coroutine style timertimer.async(function()print("coroutine1 start",os.time())timer.sleep(2)print("coroutine1 2 second later",os.time())timer.async(co3)print("coroutine1 end")end)timer.async(function()print("coroutine2 start",os.time())timer.sleep(1)print("coroutine2 1 second later",os.time())timer.sleep(1)print("coroutine2 1 second later ",os.time())timer.sleep(1)print("coroutine2 1 second later ",os.time())timer.sleep(1)print("coroutine2 1 second later ",os.time() )print("coroutine2 end")end)--callback style timerlocal stime = os.time()timer.timeout(1.5,function()print("timer expired", os.time() - stime)end)--remove a timerlocal ctx = timer.timeout(5,function()error("this timer shoud not expired")end)timer.remove(ctx)print("main thread noblock")--replace this while loop code, use your framework's updatewhile true dotimer.update()end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。