Pen Ttt wrote:
> probem1:
> the following program can only run  in irb console,it can't run with
> command :
> ruby /home/test.rb,why?
> require 'rubygems'
> require 'net/http'
> threads = []
> open("/home/pt/test/data","a+") do |wfile|
> str=%w(http://table.finance.yahoo.com/table.csv?s=IBM
> http://table.finance.yahoo.com/table.csv?s=YHOO
> http://table.finance.yahoo.com/table.csv?s=AACC)
> for page_to_fetch in str
>    Thread.new(page_to_fetch) do |url|
>     info = Net::HTTP.get_response(URI.parse(url)).body
>     puts info
>    end
>  end
> threads.each {|thr| thr.join}
> end

threads is still an empty array. Try adding each thread to threads as
you create it.
-- 
Posted via http://www.ruby-forum.com/.