multithreading - Why does exiting a Ruby thread kill my whole program? -


i have piece of code:

puts "start" loop     thread.start         puts "hello thread"         exit     end     text = gets     puts "#{text}" end puts "done" 

what expect seeing "start" followed "hello thread" , enter input echoed me. instead "start" , "hello thread" , program exits.

from documentation on exit:

terminates thr , schedules thread run. if thread marked killed, exit returns thread. if main thread, or last thread, exits process.

but thought spawned new thread? why exiting main process?

you're looking @ thread#exit documentation. kill kernel#exit terminates ruby script.

puts "start" loop     thread.start         puts "hello thread"         thread.exit     end     text = gets     puts "#{text}" end puts "done" 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -