From: Robert Klemme Date: 2009-10-21T05:05:05+09:00 Subject: Re: Threads terminating On 20.10.2009 00:34, Patrick Okui wrote: > On 20 Oct, 2009, at 1:05 AM, pawel wrote: > >> Why this simple program give no output, and terminates immidiatly >> after its launched? There should be thread running and giving lots of >> 'lala', am I right? >> class Bar >> def initialize >> >> end >> def foo >> Thread.new do > > try changing this to a = Thread.new > >> while true >> puts "lala\n" >> end >> end > > then add an a.join here > >> end >> end >> >> b=Bar.new >> b.foo > > Someone else would have to explain why that happens. Don't know enough > about threads (let alone ruby's) to explain that. All threads other than main are demon threads in Ruby, i.e. as has been explained they do not keep the process alive. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/