Created
May 21, 2016 01:55
-
-
Save DougEverly/a3d477368ad3ff629a9a39cc6da14cda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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