require 'yaml' x = YAML.load_file 'test.yml' threads = [] x[x.keys.first].keys.grep(/\d+_times/) 1_000.times do threads.push(Thread.new do end) end threads.select { |s| s.start }