"Efficiency" can mean many things. For Ruby <1.9, green threads mean you won’t get as much concurrency as you can think of from threads, so using multiple script instances would be the best way to minimize the total real time from start to finish.
, t Pickaxe "":
require 'net/http'
pages = %w( www.rubycentral.com
www.awl.com
www.pragmaticprogrammer.com
)
threads = []
for page in pages
threads << Thread.new(page) { |myPage|
h = Net::HTTP.new(myPage, 80)
puts "Fetching: #{myPage}"
resp, data = h.get('/', nil )
puts "Got #{myPage}: #{resp.message}"
}
end
threads.each { |aThread| aThread.join }