Ruby/Threads/status

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

Версия от 17:59, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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