getallthreads
Returns all Luau threads currently reachable by the calling state's garbage collector.
Syntax
getallthreads() -> {thread}Returns
| Type | Description |
|---|---|
{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))
endNotes
- 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
Related Functions
getgc- Walk other garbage-collected valuesgetscriptfromthread- Get the script associated with a thread