Namespaces
thread
Methods
get_name
Returns the name of the current thread
function thread.get_name(): string
-- example usage
local name = thread.get_name()
create
Creates a new thread with a random name and returns true if successfully created
function thread.create(routine: function, ...): bool
-- example usage
thread.create(function()
-- do something in thread
end)
create_named
Creates a new thread with the provided name and returns true if successfully created
function thread.create_named(name: string, routine: function, ...): bool
-- example usage
local thread_created = thread.create_named("Example", function()
-- do something in thread
end)
yield
Pauses execution of the calling thread until the next tick, unless
ms was provided, in which case execution will resume once the time has elapsedfunction thread.yield(ms: int? --[[0]]): void
-- example usage
local thread1_created = thread.create(function()
while true do
-- runs once every tick
thread.yield()
end
end)
local thread2_created = thread.create(function()
while true do
-- runs once every second
thread.yield(1000)
end
end)