getallthreads

Returns all Luau threads currently reachable by the calling state's garbage collector.

Syntax

getallthreads() -> {thread}

Returns

TypeDescription
{thread}A weak array containing the threads found during the GC walk

Example

local threads = getallthreads()
print("Threads found:", #threads)

for index, thread in ipairs(threads) do
    print(index, coroutine.status(thread), getscriptfromthread(thread))
end

Notes

  • The result is scoped to the caller's Luau state
  • The result table has weak values, so a thread can disappear after collection if nothing else retains it