Ruby/Threads/status
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:59, 13 сентября 2010
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