Oh I see, because of the call to Kernel.sleep forces the thread in a sleeping state.
On Oct 25, 9:55 pm, John Merlino <stoici...@aol.com> wrote: > In this example: > > 1.9.3p0 :001 > def threading > 1.9.3p0 :002?> i = 0 > 1.9.3p0 :003?> while i <= 50 > 1.9.3p0 :004?> sleep(2) > 1.9.3p0 :005?> i += 1 > 1.9.3p0 :006?> if i == 50 > 1.9.3p0 :007?> puts "the thread is finished at #{Time.now}" > 1.9.3p0 :008?> end > 1.9.3p0 :009?> end > 1.9.3p0 :010?> end > => nil > 1.9.3p0 :011 > t = Thread.new { threading } > => #<Thread:0x007f833d301660 sleep> > 1.9.3p0 :012 > t.status > => "sleep" > 1.9.3p0 :013 > t.stop? > => true > 1.9.3p0 :014 > t.alive? > => true > #few minutes later: > 1.9.3p0 :015 > the thread is finished at 2012-10-25 21:52:43 -0400 > > As soon as threading is invoked in the new thread, I check its status. > And the status is "sleep". Why is it "sleep" and not "runnable"? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.