Sha256: 9892a6e7b48ef3d6bed24c6c2bf0d92d1fdba3318a3ed04b23b4231c8eb313a4
Contents?: true
Size: 433 Bytes
Versions: 17
Compression:
Stored size: 433 Bytes
Contents
#!/usr/bin/env ruby # Adapted from Programming Ruby 2nd Ed. p. 138 require 'rubygems' 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
17 entries across 17 versions & 5 rubygems