Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2011 19:14
Show Gist options
  • Save anonymous/1521954 to your computer and use it in GitHub Desktop.
Save anonymous/1521954 to your computer and use it in GitHub Desktop.
t1 = Thread.new {
c = 'a'
25.times { print c.next!;sleep 1 }
}
t2 = Thread.new {
25.times { |i| print i;sleep 1 }
}
t1.join
t2.join
Produces: b01cd2e34fg5h6i7j8k9l10m11n12o13p14q15r1617s18t19u20v21w22x23y24z
t1 = Thread.new {
c = 'a'
25.times { print c.next!;sleep 1 }
}.join
t2 = Thread.new {
25.times { |i| print i;sleep 1 }
}.join
Produces: bcdefghijklmnopqrstuvwxyz0123456789101112131415161718192021222324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment