Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/multithreads_each/array_method.rb

Instance Method Summary collapse

Instance Method Details

#multithreads_each(options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/multithreads_each/array_method.rb', line 2

def multithreads_each(options={})
  threads = []
  without_joins = options[:without_joins]

  self.each do |n|
    threads << Thread.new { yield n }
  end

  threads.each { |thread| thread.join } unless without_joins
end