Skip to content

Instantly share code, notes, and snippets.

@edbond
Last active December 17, 2015 18:59
Show Gist options
  • Save edbond/5657089 to your computer and use it in GitHub Desktop.
Save edbond/5657089 to your computer and use it in GitHub Desktop.
require 'thread/pool'
class ChartExport
def self._threads_test
a = Queue.new
1000.times {
pool = Thread.pool(10)
100.times {
pool.process { a << 1 }
}
pool.shutdown
}
puts "Should be 100000"
puts a.size
raise "Invalid result" unless a.size == 100000
end
end
require 'thread/pool'
a = Queue.new
1000.times {
pool = Thread.pool(10)
100.times {
pool.process { a << 1 }
}
pool.shutdown
}
puts "Should be 100000"
puts a.size
raise "Invalid result" unless a.size == 100000
@edbond
Copy link
Author

edbond commented May 27, 2013

Run as:

> repeat 100 (ruby t.rb)
> repeat 5 (rails runner 'ChartExport._threads_test')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment