Created
June 23, 2009 07:08
-
-
Save vsalbaba/134407 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
#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