Skip to content

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

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>
See also .kill .main .ignore_deadlock= .new also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1