From: Li Chen Date: 2008-09-15T22:02:49+09:00 Subject: How to control thread number Hi all, I copy the following script from Ruby programming language(bundling with Ruby). If the size for pages (array size) is small,thread works very well. If the array size is big (such 2000) the thread doesn't work at or very slow. I wonder what is the best means to control thread number based on this script, read a small trunk of array at a time using each_slice method? Thanks, Li ##################### script##################### pages = %w( www.rubycentral.com www.awl.com www.pragmaticprogrammer.com ) threads = [] for page in pages threads << Thread.new(page) { |myPage| h = Net::HTTP.new(myPage, 80) puts "Fetching: #{myPage}" resp, data = h.get('/', nil ) puts "Got #{myPage}: #{resp.message}" } end -- Posted via http://www.ruby-forum.com/.