global

def run_in_thread(helpers, tests, thread_locals)

def run_in_thread(helpers, tests, thread_locals)
  shindo = Thread.new {
    for key, value in thread_locals
      Thread.current[key] = value
    end
    for file in helpers
      unless Thread.main[:exit]
        load(file)
      end
    end
    for file in tests
      Thread.current[:file] = file
      unless Thread.main[:exit]
        load(file)
      end
    end
  }
  begin
    shindo.join
  rescue
    # continue, even if threads are gone
    # see: https://github.com/geemus/shindo/issues/12
  end
  if shindo[:reload]
    run_in_thread(helpers, tests, thread_locals)
  else
    @totals = shindo[:totals]
  end
end