Module: NumThreads

Included in:
Fixnum
Defined in:
lib/num_threads.rb,
lib/num_threads/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#threads(&blk) ⇒ Object



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

def threads(&blk)
  threads = []

  self.times do
    threads << Thread.new do
      blk.call
    end
  end

  threads.each(&:join)
end