Skip to content

Instantly share code, notes, and snippets.

Created June 9, 2017 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/034453831254b82718f20079f3591063 to your computer and use it in GitHub Desktop.
Save anonymous/034453831254b82718f20079f3591063 to your computer and use it in GitHub Desktop.
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