Ruby多线程

Ruby多线程

1:Ruby多线程:main线程运行完后,会杀死其他线程,因此需要join进主线程,让主线程等待其他线程运行完后在结束

 

  1. x = Thread.new do 
  2.     puts "start" 
  3.     sleep 2 
  4.     puts "thread.." 
  5.     sleep 2 
  6.     puts "end" 
  7. end 
  8. #主线程执行完后会杀死其他的线程 
  9. "hello___" 
  10. x.join