From: Norman Makoto Su Date: 2002-03-28T11:44:20+09:00 Subject: Threads in Iterators This may be a dumb question with an obvious answer but, is it dangerous to have threads in iterators? For example: arr = [1,2,3,4] def arr.each 0.upto(length-1) do |i| Thread.new(self[i]) {|val| sleep(rand .5) # or something else that may take a while yield val } end end vals = [] arr.each {|val| vals << val } Thread.list.each do |aThread| aThread.join if aThread != Thread.current end puts vals My concern is if there is a chance that two yields will happen at the same time and mess things up (vals will be corrupted). Is this possible? Thanks, -- Norman Makoto Su