Title / Description
Code 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
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code