| 发表于:2007-02-05 11:57:473楼 得分:0 |
to 小丸子 谢谢你的建议 我之前用过这个方法 和我现在的结果一样 "hello "只输出一次。 to 透明 你说得对,我检查了任务管理器 在我的loop中cpu确实接近100% 我google到有一段thread的代码 run了一下 可以达到我的目的,附上: count=0 thread.new { while true; sleep(1); print "a "; count+=1; end } while count < 3 do end # no-op wait thread.critical = true puts "no more a 's will come out. " reference:http://www.rubycentral.com/book/ref_c_thread.html | | |
|