From: Robert Klemme Date: 2006-01-25T22:08:12+09:00 Subject: Re: threading sync Mage wrote: > Robert Klemme wrote: > >> >> In your case you probably better use a Queue which saves you the >> synchronization overhead (the Queue does it internally). Something >> along the lines of this (untested): >> >> > Thank you. I see. > > However, in cases when there is no existing solution, should I write a > tester unit that determines about a method its atomicness? IMHO it's generally a bad idea to determine thread safety properties of code by testing. The test may fail, in which case you got a definitve answer (it's unsafe). But the test may succeed and then you don't know whether it was by accident (timing) or by design / implementation. You could look at the source code of Ruby but on one hand that may change and on the other hand there will be definitively issues when Ruby 2.0 comes out and supports native threads. If you build a MT application you should design MT right into it, which also means that you have to think about which resources (aka objects) are accessed from multiple threads and how you synchronize access to them. Kind regards robert