summaryrefslogtreecommitdiff
path: root/tests/modules/thread/sleep.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/thread/sleep.lua')
-rw-r--r--tests/modules/thread/sleep.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/modules/thread/sleep.lua b/tests/modules/thread/sleep.lua
index 1890278b3..4dc350cd3 100644
--- a/tests/modules/thread/sleep.lua
+++ b/tests/modules/thread/sleep.lua
@@ -1,17 +1,20 @@
import("core.thread.thread")
function callback(id)
- print("%s: %d ..", thread.running(), id)
+ print("%s: %d starting ..", thread.running(), id)
local dt = os.mclock()
- os.sleep(1000)
+ for i = 1, 10 do
+ print("%s: %d", thread.running(), i)
+ os.sleep(1000)
+ end
dt = os.mclock() - dt
print("%s: %d end, dt: %d ms", thread.running(), id, dt)
end
function main()
- for i = 1, 10 do
- thread.start_named("thread_" .. i, callback, i)
- end
- --thread.wait()
+ local t0 = thread.start_named("thread_0", callback, 0)
+ local t1 = thread.start_named("thread_1", callback, 1)
+ thread.wait(t0, -1)
+ thread.wait(t1, -1)
end