Files
soldr-modules/tests/test_thread.lua
T
2022-11-22 02:21:28 +03:00

17 lines
412 B
Lua

local thread = require("thread")
local thds = {}
local function worker1(ctx)
print("hello from thread:", ctx.id)
return ctx.id
end
local function worker2(ctx)
print("hello from thread:", ctx.id)
return ctx.id
end
table.insert(thds, thread.new(worker1, {id=1}))
table.insert(thds, thread.new(worker2, {id=2}))
for _, thd in ipairs(thds) do print("join from main:", thd:join()) end
print("done")