我刚刚使用之前使用的模型向现有程序添加了线程,但这次线程没有执行,所以我添加了
Thread.new {puts "thread" }
exit
在程序的顶部,它没有打印任何东西就退出了。
诊断请求问题的指针。
Linux (ubuntu) ruby 2.7给定代码…
Thread.new {puts "thread" }
exit
. .不能保证执行puts
。你必须join
线程。
t = Thread.new {puts "thread" }
t.join # block until thread finishes
exit