Skip to content

thread


get_name

string thread.get_name()

Returns the name of the current thread
Example Usage
local name = thread.get_name()

create

bool thread.create(function routine, ...)

Creates a new thread with a random name and returns true if successfully created
Example Usage
thread.create(function()
    -- do something in thread
end)

create_named

bool thread.create_named(string name, function routine, ...)

Creates a new thread with the provided name and returns true if successfully created
Example Usage
thread.create_named("Example", function()
    -- do something in thread
end)

yield

void thread.yield(int? ms)

Pauses execution of the calling thread until the next tick, unless 'ms' was provided, in which case execution will resume once the time has elapsed
Example Usage
-- example 1
thread.create(function()
    while true do
        -- runs once every tick
        thread.yield()
    end
end)

-- example 2
thread.create(function()
    while true do
        -- runs once every second
        thread.yield(1000)
    end
end)