End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Thread.list
Thread.list → array
thread.c
View on GitHub ↗
static VALUE
thread_list(VALUE _)
{
return rb_thread_list();
}
Returns an array of Thread objects for all threads that are either runnable or stopped.
Example
Thread.new { sleep(200) } Thread.new { 1000000.times {|i| i*i } } Thread.new { Thread.stop } Thread.list.each {|t| p t}
This will produce:
Example
#<Thread:0x401b3e84 sleep> #<Thread:0x401b3f38 run> #<Thread:0x401b3fb0 sleep> #<Thread:0x401bdf4c run>