Ruby/Threads/status

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Check the thread status

t1 = Thread.new { loop {} }
t2 = Thread.new { sleep 5 }
t3 = Thread.new { Thread.stop }
t4 = Thread.new { Thread.exit }
t5 = Thread.new { raise "exception" }
puts s1 = t1.status    # "run"
puts s2 = t2.status    # "sleep"
puts s3 = t3.status    # "sleep"
puts s4 = t4.status    # false
puts s5 = t5.status    # nil