diff options
Diffstat (limited to 'tests/modules/thread/sleep.lua')
| -rw-r--r-- | tests/modules/thread/sleep.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/modules/thread/sleep.lua b/tests/modules/thread/sleep.lua new file mode 100644 index 000000000..2e21aa3d2 --- /dev/null +++ b/tests/modules/thread/sleep.lua @@ -0,0 +1,21 @@ +import("core.base.thread") + +function callback(id) + import("core.base.thread") + print("%s: %d starting ..", thread.running(), id) + local dt = os.mclock() + 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() + local t0 = thread.start_named("thread_0", callback, 0) + local t1 = thread.start_named("thread_1", callback, 1) + t0:wait(-1) + t1:wait(-1) +end + |
