normandy/examples/many_to_one.rb
2015-08-03 13:50:05 +02:00

15 lines
281 B
Ruby

# http://stackoverflow.com/questions/15715605/multiple-goroutines-listening-on-one-channel
require 'channel'
c = Channel.new
1.upto(5) do |i|
go(lambda { |i, co|
1.upto(5) do |j|
co << format("hi from %d.%d", i, j)
end
}, i, c)
end
25.times { puts c.recv }