MyTestProgram
Ruby
code posted
by
Edward Xie
created at 15 Feb 17:43
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
require "net/http" #class ThreadTest # To change this template use File | Settings | File Templates. pages = %w(www.rubycentral.com www.eclipse.org www.baidu.net) threads = [] for page_to_fetch in pages threads << Thread.new(page_to_fetch) do |url| h = Net::HTTP.new(url, 80) puts "Fetching: #{url}" resp = h.get('/') puts "Got: #{url}: #{resp.message}" end end threads.each{|thr| thr.join} #end |
466 Bytes in 2 ms with coderay