def get_proxy good = [] threads = [] ls_prx = Proxy.new proxy_ls = ls_prx.get_all proxy_ls.each do |test_prx| proxy_thread = Thread.new do res = Proxy.new if res.test_active(test_prx) && !@used_proxy.include?(test_prx) then good << test_prx puts "#{test_prx} good" else #puts "#{test_prx} not good" end threads << proxy_thread end end threads.each do |thread| thread.join end puts "#{good}" return good.first end