From: Pit Capitain Date: 2008-08-20T05:05:32+09:00 Subject: Re: Newly created thread blocks all others in Ruby 1.8.7 patchlevel 72 on Cygwin 2008/8/19 Daniel Merk : > I am using the following Ruby version: > > ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] Hello Daniel, I don't have 1.8.7 yet, I don't have cygwin, and... > I have problems with threads now that did not occur in Ruby 1.8.6. ...and I don't think that what you see is a problem. It may be that on 1.8.6 you saw a different behavior, but I still don't think that the new behavior is a problem, because AFAIK Ruby doesn't guarantee that threads with equal priority do get equal time to run. If you create a thread with > a = Thread.new do > loop { count1 += 1 } > end then Ruby starts the thread as documented. I think it's perfectly legal that Ruby runs only the new thread without scheduling other threads, including the main thread, as long as there's no other thread with higher priority. > a.priority = -1 If you finally get there, then it should be the main thread again who is blocking thread "a". > b = Thread.new do > loop { count2 += 1 } > end Here the same applies as above. Thread "b" could run all the time. > b.priority = -2 Now it should be: main thread blocks "a" blocks "b". > sleep 1 #=> 1 Give "a" some more time to run. > Thread.critical = 1 > > puts "count1: #{count1}" > puts "count2: #{count2}" > > This code never starts thread b. It seems that thread a blocks all > other threads once it runs (though its priority is lowered), even the > main thread. See above. I think that's ok. What behavior do you expect? Or better: what do you want to achieve? Regards, Pit