Is it still alive, stopped : alive « Threads « Ruby






Is it still alive, stopped


count = 0
t1 = Thread.new { loop { count += 1 } }
t2 = Thread.new { Thread.stop }
sleep 1

puts t1.alive?    # true
puts t1.stop?     # false
puts t2.alive?    # true
puts t2.stop?     # true

 








Related examples in the same category