29 Jan '13, 10pm
"Ruby Arrays aren't thread-safe, [...] MRI's threading implementation accidentally makes them thread-safe."
Just Another Victim of the Ambient Morality wrote: > Are all built-in objects thread safe? For example, if I have an array > and one thread is constant appending to it while another thread is shifting > elements off of it and there's no synchronization going on, can the array > object ever get corrupted? What about a similar scenario for hashes? These > are surely complicated objects with internal state that must be maintained. > Are they implemented to be thread safe? This is a *very* interesting question! And it is a question that can ultimately *only* be answered by a formal Ruby Specification or more specifically a formal Ruby Memory Model. Until we have such a specification, the C source code of MRI or YARV is considered to be the "specfication". However, there is a problem: that source code can actually be interpreted several different ways. If you look at the implem...