Skip to content

Instantly share code, notes, and snippets.

@takai
Created November 9, 2011 20:16
Show Gist options
  • Save takai/1352847 to your computer and use it in GitHub Desktop.
Save takai/1352847 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bundler/setup'
require 'mysql2'
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(:adapter => 'mysql2',
:host => 'localhost',
:database => 'test',
:username => 'root',
:pool => 1)
class Employee < ActiveRecord::Base
end
ts = []
10.times do
ts << Thread.new do
ActiveRecord::Base.connection_pool.with_connection do
Employee.all
end
end
end
ts.each { |t| t.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment