Created
          April 7, 2012 02:41 
        
      - 
      
- 
        Save carlcrott/2324632 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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