From: Brian Candler Date: 2008-12-24T18:28:18+09:00 Subject: Re: Are all Ruby built-in objects thread safe? Just Another Victim wrote: > I don't think this is relevant. Concurrency isn't about how many > processors you use. Multitasking systems existed long before SMP > hardware > existed. Concurrency is about doing tasks concurrently. If you have > one > method running and it may be preempted by another method then they are > running concurrently. If the two methods share data then they may > corrupt > that data for each other. This is true regardless of how these > concurrencies, or threads, are implemented. It doesn't matter if > they're > hardware supported system threads or if they're Ruby green threads... Not exactly. Ruby green threads aren't fully pre-emptive; they will only pre-empt at the boundaries between execution steps, not within an execution step. Hence the single operations @array.pop and @array.push(...) are safe against preemption. You could consider each method call to be wrapped implicitly by Thread.critical { ... } -- Posted via http://www.ruby-forum.com/.