From: Paul Brannan Date: 2002-03-28T23:26:22+09:00 Subject: Re: Threads in Iterators On Thu, Mar 28, 2002 at 11:44:20AM +0900, Norman Makoto Su wrote: > 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? If you are concerned about this, then use a mutex around code that might corrupt your data: m = Mutex.new arr.each do |val| @mutex.synchronize do vals << val end end I think appending onto vals like this should be an atomic operation (so the mutex isn't necessary), but if you had a non-atomic operation, then you would definitely need a mutex. Paul