Project

General

Profile

Bug #11642

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

http://ruby-doc.org/core-1.9.3/Thread.html 

 list → array click to toggle source 
 Returns an array of Thread objects for all threads that are either runnable or stopped. 

 ~~~ruby 
 Thread.new { sleep(200) } 
 Thread.new { 1000000.times {|i| i*i } } 
 Thread.new { Thread.stop } 
 Thread.list.each {|t| p t} 
 ~~~ 
 produces: 

 WRONG: 

 ~~~ 
 <Thread:0x401b3e84 sleep> 
 <Thread:0x401b3f38 run> 
 <Thread:0x401b3fb0 sleep> 
 <Thread:0x401bdf4c run> 
 ~~~ 

 RIGHT: 

 ~~~ 
 <Thread:0x00000000983c30 run> 
 <Thread:0x00000000961ef0 sleep> 
 <Thread:0x00000000961d88 dead> 
 <Thread:0x00000000961c48 sleep> 
 ~~~ 
 

Back