Skip to content

Instantly share code, notes, and snippets.

@toretore
Last active August 29, 2015 14:07
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 toretore/effc9c344cde4e1c8cd5 to your computer and use it in GitHub Desktop.
Save toretore/effc9c344cde4e1c8cd5 to your computer and use it in GitHub Desktop.
require 'thread'
queues = Array.new(10){ Queue.new }
list_of_hosts.each_slice(10).map{|s| s.each_with_index{|h,i| queues[i] << h } }
threads = 10.times.map do |i|
Thread.new do
while host = queues[i].pop
check host
end
end
end
threads.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment