From: Yohanes Santoso Date: 2005-07-26T13:35:22+09:00 Subject: Re: Ruby and threads "John Wells" writes: > Guys, > > Was looking through the forums at ruby-ide.com when I noticed the > following comment: > > "Unfortunately i can't use ruby for scripting/extending/implementing as > ruby does not work with multiple native threads and i already have one > ruby thread that is doing the background parsing." > > Can anyone elaborate on this? How does it effect folks developing in > Ruby, and curiously, why does Python seem to support it and Ruby > doesn't? I can come up with only two significant downsides of green threading that ruby has: 1. inability to use multiple cpus to run multiple threads, 2. blocked process. (2) is usually caused by disk io waiting for disk readiness. this is not monitorable in most unix (windows too?). the whole process would block until the disk is ready. (2) is also caused by certain functions in some c extension libraries. python's supports for native threading effectively eliminates these two downsides, but also introduce another downside. threads executing python code would need to obtain the global interpretter lock. This means at any given moment, there is still only one thread executing python code. In addition, the cost of acquiring the lock increases with the number of threads. But this setup eliminates (1) and (2). YS. > > Thanks for your insight! > > John