Method: Thread#alive?

Defined in:
thread.c

#alive?Boolean

Returns true if thr is running or sleeping.

thr = Thread.new { }
thr.join                #=> #<Thread:0x401b3fb0 dead>
Thread.current.alive?   #=> true
thr.alive?              #=> false

See also #stop? and #status.

Returns:

  • (Boolean)


2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
# File 'thread.c', line 2694

static VALUE
rb_thread_alive_p(VALUE thread)
{
    rb_thread_t *th;
    GetThreadPtr(thread, th);

    if (rb_threadptr_dead(th))
  return Qfalse;
    return Qtrue;
}