Created
April 1, 2010 04:49
-
-
Save stevegraham/351374 to your computer and use it in GitHub Desktop.
This file contains 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
require "rubygems" | |
require "active_record" | |
require 'mysqlplus' | |
Mysql.class_eval { alias :query :async_query } | |
ActiveRecord::Base.establish_connection( | |
:adapter => "mysql", | |
:username => "root", | |
:database => "test", | |
:pool => 40 | |
) | |
threads = [] | |
40.times do | |
threads << Thread.new do | |
ActiveRecord::Base.connection_pool.with_connection do |conn| | |
res = conn.execute("select sleep(1)") | |
end | |
end | |
end | |
# block and wait for all threads to finish | |
threads.each { |t| t.join } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment