Skip to content

Instantly share code, notes, and snippets.

@nwjsmith
Created October 12, 2016 17:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjsmith/a2f944775a41ddf2a5e9af6d6d51a90e to your computer and use it in GitHub Desktop.
Save nwjsmith/a2f944775a41ddf2a5e9af6d6d51a90e to your computer and use it in GitHub Desktop.
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