Skip to content

Instantly share code, notes, and snippets.

@DougEverly
Created May 21, 2016 01:55
Show Gist options
  • Select an option

  • Save DougEverly/a3d477368ad3ff629a9a39cc6da14cda to your computer and use it in GitHub Desktop.

Select an option

Save DougEverly/a3d477368ad3ff629a9a39cc6da14cda to your computer and use it in GitHub Desktop.
ch = Channel(Nil).new
alias TH = Thread(Nil, Nil)
threads = Array(TH).new
threads << TH.new do
6.times do
sleep 1
puts 1
end
ch.send(nil)
nil
end
threads << TH.new do
3.times do
sleep 2
puts 2
end
ch.send(nil)
nil
end
# sleep
# x.join
# y.join
threads.size
# threads.size.times { ch.receive ; puts "gots" }
ch.receive
ch.receive
# threads.each { |t| t.join }
puts "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment