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?
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?
uris.threadify(2) do |uri|
tid = Thread.current.object_id
response = open(uri){|fd| fd.read}
puts "#{ tid } : #{ uri } => #{ response[0,42].inspect }"
end
a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama