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.stop

Thread.stop → nil

Stops execution of the current thread, putting it into a “sleep” state, and schedules execution of another thread.

Example
a = Thread.new { print "a"; Thread.stop; print "c" }
sleep 0.1 while a.status!='sleep'
print "b"
a.run
a.join
#=> "abc"
See also #stop? .start #[] .report_on_exception= also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1