util.thread.current

Shared

Retrieves the currently running thread instance


Syntax

local result = util.thread.current()

Parameters

No parameters are accepted by this function

Returns

TypeNameDescription
thread | boolresultCurrently running thread instance, false if no thread is active

Examples

Retrieve the currently running thread from within a thread
local entity = util.thread.create(function(self)
    core.engine.print("info", "Running thread:", util.thread.current())
end)

entity:resume()
Check whether code is running inside a thread
local running = util.thread.current()

if not running then
    core.engine.print("info", "Not inside a thread")
end

On this page