- def what_you_want(i)
- puts "hi #{i}"
- sleep i
- puts "bye #{i}"
- end
- threads = []
- 3.times do |i| threads << Thread.new do
- begin
- what_you_want(i+1)
- threads.each do |t|
- t.kill! unless t == Thread.current
- end
- rescue
- puts "uh-oh"
- end
- end
- end
- sleep 5
- puts "done"