Class: Integer

Inherits:
Object show all
Defined in:
lib/threading_test_tools.rb

Instance Method Summary collapse

Instance Method Details

#threads(&block) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/threading_test_tools.rb', line 201

def threads(&block)
  threads = []
  self.times do |i|
    threads << Thread.start do
      begin
        Thread.critical = true
        block.call(i)
      ensure
        Thread.critical = false
      end
    end
  end
  threads.map { |thread| thread.value }
end