From: Joel VanderWerf Date: 2006-05-28T02:57:39+09:00 Subject: Re: Ruby Threads... Francis Cianfrocca wrote: ... > Threads can be used for two basic purposes: to make your programs run > faster, or to make them easier to write. Ruby's (and Java's) threads seem > designed primarily to facilitate the latter. You can easily imagine several > kinds of problems that are easier to model if you have access to relatively > independent flows of control. Thus both languages have the "synchronize" > method, taking an arbitrary code block, which makes it easy to lock > relatively large chunks of code in "critical sections" without having to > really design proper synchronization sets. You probably mean "Thread.critical" or "Thread.exclusive", and not "synchronize", at least in the context of ruby. (There is a Mutex#synchronize and of course that does require you to think about synchronization sets and ordering.) > But to effectively use threads for higher performance and concurrency > requires a large amount of experience and understanding, much of which > takes > platform dependencies into account. For just one example, I would want to > use a spin lock in some situations, if I'm running on a multi-processor > machine on certain hardware platforms. Ruby doesn't have one. Doesn't have one and doesn't need one, as long as threads are green. But, someday, when ruby has native threads, it will need spin locks. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407