Skip to content

Instantly share code, notes, and snippets.

@sandofsky
Created May 13, 2010 04:37
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 sandofsky/399498 to your computer and use it in GitHub Desktop.
Save sandofsky/399498 to your computer and use it in GitHub Desktop.
require 'thread'
t = ARGV[0].to_i
c = ARGV[1].to_i
0.upto(t) do |i|
thread = []
0.upto(c) do |j|
thread[j] = Thread.new { }
end
0.upto(c) do |j|
thread[j].join
end
end
puts "Done"
# time ruby ./threadtest.rb 400 1000
#
# Done
#
# real 0m7.370s
# user 0m6.679s
# sys 0m0.687s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment