types.Thread.getstatus
Method on every
threadReturns the thread's current state as a string.
Return value
One of:
"idle"- never started, or its function already returned or threw"running"- currently executing (only observable from inside itself, or from a nested thread it started)"suspended"- paused in asuspendcall, waiting forwakeuporwakeupthrow
Notes
A thread has no "dead" state: once its function returns or throws, it goes back to "idle", the same state it started in, and call on it starts the function over. Compare types.Generator.getstatus, whose generator goes to a permanent "dead" instead.
Example
function body() { suspend(); return "done" }
let t = newthread(body)
println("before the first call =", t.getstatus())
t.call()
println("after call(), parked on suspend =", t.getstatus())
t.wakeup()
// back to idle: a thread has no permanent dead state, unlike a generator
println("after wakeup(), body finished =", t.getstatus())Output:
before the first call = idle
after call(), parked on suspend = suspended
after wakeup(), body finished = idleSee also
call | Starts the thread's function, passing every argument straight through to it. |
wakeup | Resumes a suspended thread, passing one value back to its suspend call. |
| thread | class index |