Lua使用sys.taskInit开启任务线程,如何关闭呢

请先 登录 后评论

1 个回答

技术销售Delectate
擅长:IT

require "sys"

exit_loop = false


sys.taskInit( function()

                        while true do

                            print("this is a test")

                            sys.wait(100)            --sleep 100ms

                            if exit_loop == true then break end            --检查变量,如果是true,则break,退出循环;

                                                                                              --while循环停止,该任务停止

                        end

                    end

)


sys.timerStart(function() exit_loop = true, 15000)        --15秒后,更改变量值

请先 登录 后评论
  • 0 关注
  • 0 收藏,3757 浏览
  • 景景1993 提出于 2018-09-21 15:42

相似问题