End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Thread#stop?
thr.stop? → true or false
thread.c
View on GitHub ↗
static VALUE
rb_thread_stop_p(VALUE thread)
{
rb_thread_t *th = rb_thread_ptr(thread);
if (rb_threadptr_dead(th)) {
return Qtrue;
}
else if (th->status == THREAD_STOPPED ||
th->status == THREAD_STOPPED_FOREVER) {
return Qtrue;
}
else {
return Qfalse;
}
}
Returns true if thr is dead or sleeping.
Example
a = Thread.new { Thread.stop } b = Thread.current a.stop? #=> true b.stop? #=> false