Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Thread.kill

Thread.kill(thread) → thread

Causes the given thread to exit, see also Thread::exit.

Example
count = 0
a = Thread.new { loop { count += 1 } }
sleep(0.1)       #=> 0
Thread.kill(a)   #=> #<Thread:0x401b3d30 dead>
count            #=> 93947
a.alive?         #=> false
See also #kill .ignore_deadlock= .list .ignore_deadlock also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0