I'm writing a script that will ping my ip range. Here's what I have so far:
lines = `ipconfig`.split("\n") thr = [] ip_line = lines.detect { |l| l=~/Ip Address/i } matcher = /\d+\.\d+\.\d+\.\d+/.match(ip_line) if matcher.length > 0 address = matcher[0] address.sub!(/\.\d+$/,"") (1 .. 254).each do |i| xaddr = address + "." + i.to_s puts "pinging #{xaddr}" thr << Thread.new { `ping #{xaddr}` } end thr.each do |t| t.join output = t.value puts output end end The thing is, this executes extremely slow. Like the app isn't threaded. Why is that? I noticed that if I subclass Thread, the whole thing runs much, much faster. What's wrong? Isn't Thread intended for direct usage?