Created
May 6, 2012 17:54
-
-
Save pochi/2623517 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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