From: Mark Hahn Date: 2001-12-20T09:01:37+09:00 Subject: [ruby-talk:29038] Re: A Ruby programmer walked into a bar and ordered a Ruby-Thread I don't understand the problem. I just ran this on windows: Thread.new {loop{print 'a';sleep(0.1)}} Thread.new {loop{print 'b';sleep(0.214)}} sleep(2) ==> abaabaabaabaabaabaabaabaaabaab If you are talking about two greedy threads that both ask for 100% of the cpu, then that is bad coding and the result is unpredictable. This is true in any threading environment. Now processes are a different matter. They are supposed to be pre-emptive and asking for 100% of the cpu is perfectly ok. -----Original Message----- From: HarryO [mailto:harryo@zipworld.com.au] Sent: Wednesday, December 19, 2001 3:28 PM To: ruby-talk ML; undisclosed-recipients: Subject: [ruby-talk:29036] Re: A Ruby programmer walked into a bar and ordered a Ruby-Thread On Thu, 20 Dec 2001 07:58:47 +1100, Dave Thomas wrote: > Well, not really. Under Windows, there doesn't seem to be any switching > between threads in some circumstances. Each thread runs to completion, > and then another starts. Although arguably correct in a theoretical > sense, it isn't much use in practice. Under Unix, threads play nicely > with each other (hence the example with counters in the book). In which case, the concept that the threading is done in the interpreter to make it OS independent seems a little "dodgey" for want of a better word. There's not a lot of point having threads if they don't effectively run in parallel. Maybe there needs to be more emphasis on this made in documentation somewhere ... maybe it is and I just haven't seen it because I'm not overly interested in Windows. Obviously, Ruby is still a wonderful thing to have, even on Windows, but if one specifically wanted to do multithreading, it would be a little annoying to go to the effort, only to discover that it didn't work as you'd expect threading to work .. ie, in a natural, straightforward way. > The interpreter is not thread safe, and the consensus seems to be that > making it so would be a waste of time, given the upcoming rewrite. A > secondary issue is the extensions that are already out there. How many > of there are also not thread safe, and what impact would running under a > native threading model have on them? Yes, I guess when 2.0 comes out, this will all become a non-issue, so as a Linux user, I'll content myself with being sympathetic towards the Windows Ruby-ists until then :-).