summaryrefslogtreecommitdiff
path: root/tests/modules/thread/sleep.lua
blob: 9f7bb859c6c36589254530ace27b73cac6c8525b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import("core.thread.thread")

function callback(id)
    print("hello")
    --[[
    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