1
我有以下腳本(紅寶石1.9.3),如果我註釋掉兩個螺紋線,它工作正常,如果我留下他們在我得到一個500內部錯誤網絡服務器。爲什麼這在CGI中不起作用,但在命令行上工作正常?我如何讓線程工作在紅寶石CGI
#!/usr/bin/ruby
require 'rubygems'
require 'cgi'
print "Content-type: text/html\n\n"
TIMEOUT = 8
def worker(data, results)
results[data] = rand(6)
end
if __FILE__ == $PROGRAM_NAME
results = {}
worker("abc", results)
t = Thread.new{ worker("xyz", results) }
t.join(TIMEOUT)
print results
print "done"
end