types.Thread.tostring
Method on every
threadtostring(): 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
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
getstatus | Returns the thread's current state as a string. |
tostring | Returns a string that names the type and identity of the table. |
| thread | class index |