Skip to content

Instantly share code, notes, and snippets.

@nwjsmith

nwjsmith/htttp.rb

Created Oct 12, 2016
Embed
What would you like to do?
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