J. Ryan Sobol escribióº > On Dec 23, 2005, at 5:23 PM, Ilmari Heikkinen wrote: > >> On 12/23/05, J. Ryan Sobol <ryansobol / gmail.com> wrote: >> >>> On Dec 23, 2005, at 4:13 PM, Ilmari Heikkinen wrote: >>> >>>> [kig@jugend:~] ruby fw_test.rb >>>> puts in different threads seems to be atomic >>> >>> >>> Crafty test program. Coincidentally, my results differ from yours. >>> >>> $ ruby fw_test.rb >>> puts in different threads isn't atomic >>> $ ruby -v >>> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.3.0] >> >> >> Good! I thought it was odd that they seemed to be atomic.. >> >> And now we know to mutex disk writes (or use flock.) >> >>> I'm getting 8 unique lines in File.readlines(fn).uniq, as opposed to >>> the 3 thread objects in ts. Assuming I understand the program, that >>> means threads are not waiting their turn like they should. FYI, I've >>> compiled my own ruby executable from DarwinPorts instead of using the >>> 'broken' one shipped in OS X Tiger. >>> >>> However, if I change the multiplication factor in line 3 to 655, then >>> >>> $ ruby fw_test.rb >>> puts in different threads seems to be atomic >> >> >> I don't know the reason (can guess, but too unsure) >> Explanation anyone? >> >>> ~ ryan ~ >>> >>> PS - I love the 205+ MB of text this app generates! :-D >> >> >> Ilmari > > > Regardless, the important thing is to know that it seems file IO via > puts is not thread safe, which I kind of assumed from the beginning. > This begs the question: which methods, especially concerning file IO, > are thread safe? (if any) > > ~ ryan ~ > > Hey!!.... I'm now more confused than before posting :-D