1
0

threading_helpers.rb 317 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. module ThreadingHelpers
  3. def multi_threaded_execution(thread_count)
  4. wait_for_start = true
  5. threads = Array.new(thread_count) do
  6. Thread.new do
  7. true while wait_for_start
  8. yield
  9. end
  10. end
  11. wait_for_start = false
  12. threads.each(&:join)
  13. end
  14. end