Skip to content

Instantly share code, notes, and snippets.

@pochi
Created May 6, 2012 17:54
Show Gist options
  • Save pochi/2623517 to your computer and use it in GitHub Desktop.
Save pochi/2623517 to your computer and use it in GitHub Desktop.
# coding: utf-8
require "net/http"
require "uri"
def ping_pong(num)
loop do
puts "#{num.to_s}"
uri = URI.parse 'http://localhost:8080/waiting'
res = Net::HTTP.start(uri.host, uri.port).get(uri.path)
EM::stop if res.code.to_i == 200
end
end
threads = []
10.times do |i|
threads << Thread.new(i) do |num|
ping_pong(num)
end
end
threads.each { |t| t.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment