Created
October 12, 2016 17:30
-
-
Save nwjsmith/a2f944775a41ddf2a5e9af6d6d51a90e to your computer and use it in GitHub Desktop.
This file contains 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' | |
require 'thread' | |
require 'uri' | |
uri = URI('http://theinternate.com') | |
response_queue = Queue.new | |
threads = (1..3).map do | |
Thread.new do |thread| | |
response_queue << Net::HTTP.get_response(uri) | |
end | |
end | |
# Wait for finish | |
threads.each(&:join) | |
until response_queue.empty? | |
response = response_queue.pop | |
puts response.code | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment