Quirrel4.41.0

types.Thread.tostring

Method on every thread
tostring(): any

Returns a string that names the type and identity of the thread.

Return value

A string shaped like (thread : 0x...), whatever state the thread is in. The address is the thread's own identity: two threads created from the same function print two different addresses.

Notes

Takes no arguments; t.tostring(1) throws wrong number of parameters passed to native closure 'tostring' (2 passed, 1 required).

Because the address changes from run to run, code must never compare or print tostring() of a thread for anything other than a human to eyeball while debugging.

Example

examples/types/thread/tostring.nut
function body() { suspend() }
let t = newthread(body)
let s = t.tostring()
println("s.slice(0, 9) =", s.slice(0, 9)) // "(thread :"
try { t.tostring(1) } catch(e) { println("t.tostring(1) throws:", e) }
Output:
s.slice(0, 9) = (thread :
t.tostring(1) throws: wrong number of parameters passed to native closure 'tostring' (2 passed, 1 required)

See also

getstatusReturns the thread's current state as a string.
tostringReturns a string that names the type and identity of the table.
threadclass index