Mega Code Archive

 
Categories / Ruby / Threads
 

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