From: David Masover Date: 2009-12-07T05:22:03+09:00 Subject: Re: how about ruby's threads? First, it's just a preference, but I think most on the list agree to me -- please don't top-post. Start your post after the quote, preferably after the relevant section. On Saturday 05 December 2009 10:00:14 pm Ruby Newbee wrote: > Well, I asked this because Perl thread documentation warns that > multithreading should not be used in production systems. I don't know of any similar limitation in Ruby, but I will say that you probably shouldn't use Ruby threads in production systems. That doesn't have anything to do with Ruby, it has to do with the concept of threads in general. > And Perl's threads has many limitations, as this article said: > http://www.perlmonks.org/index.pl?displaytype=print;node_id=288022 This lists one limitation and one weird design feature. The weird design feature is that apparently Perl threads don't share variables -- this is like fork(), and you may as well use fork anyway. The one thing they give you that fork doesn't is "shared variables" -- so you can explicitly share variables between threads. Ruby doesn't do this. In Ruby, all variables are essentially shared between threads, and I'm pretty sure there aren't massive data structures copied between threads, so they're much lighter weight than Perl threads. But this means that any time you change a variable that _might_ be visible elsewhere in your program, you have to make sure you synchronize access (with locks and such). So Ruby threads will probably be faster, but much more dangerous than Perl threads unless you know what you're doing. > Python's is better. I would guess Ruby threads are similar to Python. All that said, you are probably asking the wrong question: http://dobbscodetalk.com/index.php?option=com_myblog&show=Threads-considered- harmful.html&Itemid=29 The question you are asking is, "Are Ruby threads at least as good as Python threads?" The answer to that is probably yes, and better if you use JRuby. The question you should be asking is, "What's the best way to handle concurrency in Ruby?" The answer is, it depends what you're doing, but it's probably not threads.