Sha256: a67b899f2729e8b600465a043ab416f42f2bf6f29dcdf9acddb13508836977b4

Contents?: true

Size: 413 Bytes

Versions: 11

Compression:

Stored size: 413 Bytes

Contents

#!/usr/bin/env ruby
# Adapted from Programming Ruby 2nd Ed. p. 138

unless defined?(Debugger)
  puts "This program has to be called from the debugger"
  exit 1
end

def fn(count, i)
  sleep(rand(0.1))
  if 4 == i
    debugger
  end
  Thread.current['mycount'] = count
end

count = 0
threads = []
5.times do |i|
  threads[i] = Thread.new do
    fn(count, i)
    count += 1
    end
  end
threads.each {|t| t.join }

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
debugger-1.2.4 test/thread1.rb
debugger-1.2.3 test/thread1.rb
debugger-1.2.2 test/thread1.rb
debugger-1.2.1 test/thread1.rb
debugger-1.2.0 test/thread1.rb
debugger-1.1.4 test/thread1.rb
debugger-1.1.3 test/thread1.rb
debugger-1.1.2 test/thread1.rb
debugger-1.1.1 test/thread1.rb
debugger-1.1.0 test/thread1.rb
debugger-1.0.1 test/thread1.rb