From: "Aleksi Niemelä" Date: 2000-07-06T16:04:48+02:00 Subject: [ruby-talk:03872] Re: Multithreaded/Embedded Ruby? > So in this case, nobody has answered my question: Is the Ruby > interpreter thread safe No it's not as an interpreter, a program. You can't make multithreaded C program calling the interpreter to execute programs simultaneously. Or you can, but you have to setup thread-safety features by yourself. But however it's thread-safe as a executor of Ruby code. There can be multiple threads of Ruby code running simultaneously on one single interpreter. Even then, you have to arrange mutexes for the data etc. There're few stadard libraries for that. In any case we have to define what we're talking about with thread-safety. Is it the fact that the code will run most of the time concurrently without messing up data or getting into death-lock? Or is about re-entrantness? Inside Ruby re-entrantness is not guaranteed, but most of the time things work. They don't work particularly when the method call assings the result on a global variable and you rely on that. But the same thing applies to all languages -- while some languages might have designed their libraries quite well, so there's none or almost at all side effects. (Ruby is close to that and methods making side effects are documented and do that only for convenience of non-concurrent programmers.) - Aleksi