Skip to content

Instantly share code, notes, and snippets.

@vsalbaba
Created June 23, 2009 07:08
Show Gist options
  • Save vsalbaba/134407 to your computer and use it in GitHub Desktop.
Save vsalbaba/134407 to your computer and use it in GitHub Desktop.
#simple addition to Integer to help user friendly multithreading. Will execute block in separate threads selftimes. will not wait for each thread to finish, possible update on that.
#example:
# 3.co_times do |i|
# puts "i"
# end
##=> 0 2 1
# 5.co_times do
# something
# end
#
class Integer
def co_times &blk
self.times do |i|
Thread.new do
yield i
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment