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
thread.c
View on GitHub ↗
static VALUE
rb_thread_s_kill(VALUE obj, VALUE th)
{
return rb_thread_kill(th);
}
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