Created
June 9, 2017 20:09
-
-
Save anonymous/034453831254b82718f20079f3591063 to your computer and use it in GitHub Desktop.
This file contains 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
channel= Channel(Int32).new | |
spawn do | |
p "Start1: #{Time.now}" | |
i= 0 | |
100_000_000.times do | |
channel.send i=-1 | |
channel.receive | |
end | |
p "End1: #{Time.now}" | |
end | |
spawn do | |
p "Start2: #{Time.now}" | |
i= 0 | |
100_000_000.times do | |
channel.receive | |
channel.send i+= 1 | |
end | |
p "End2: #{Time.now}" | |
end | |
Fiber.yield |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment