Skip to content

Instantly share code, notes, and snippets.

@carlcrott
Created April 7, 2012 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlcrott/2324632 to your computer and use it in GitHub Desktop.
Save carlcrott/2324632 to your computer and use it in GitHub Desktop.
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 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment