@
Askiz 我刚测试了,是异步的,os.clock() 计算的时间不对,估计它只算父协程的时间,不包括轻线程的
你用我这段代码试试
```
local function test(name, sec)
ngx.say(name .. " start: " .. ngx.localtime())
ngx.sleep(sec)
ngx.update_time()
ngx.say(name .. " --end: " .. ngx.localtime())
end
ngx.say("pages start: " .. ngx.localtime())
ngx.thread.spawn(test, 'test1', 1)
ngx.thread.spawn(test, 'test2', 2)
ngx.update_time()
ngx.say("pages --end: " .. ngx.localtime())
```
pages start: 2022-07-26 23:11:44
test1 start: 2022-07-26 23:11:44
test2 start: 2022-07-26 23:11:44
pages --end: 2022-07-26 23:11:44
test1 --end: 2022-07-26 23:11:45
test2 --end: 2022-07-26 23:11:46