Skip to content

Instantly share code, notes, and snippets.

@stevegraham
Created April 1, 2010 04:49
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 stevegraham/351374 to your computer and use it in GitHub Desktop.
Save stevegraham/351374 to your computer and use it in GitHub Desktop.
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