Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Thread#stop?
() -> bool
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;
}
return RBOOL(th->status == THREAD_STOPPED || th->status == THREAD_STOPPED_FOREVER);
}
Returns true if thr is dead or sleeping.
Example
a = Thread.new { Thread.stop } b = Thread.current a.stop? #=> true b.stop? #=> false