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