matz / netlab.co.jp (Yukihiro Matsumoto) writes:

> Hi,
> 
> In message "[ruby-talk:03059] Thread priorities"
>     on 00/05/31, Dave Thomas <Dave / thomases.com> writes:
> 
> |Thread priorities don't seem to have any effect:
> |
> |        c1 = 0
> |        c2 = 0
> |        a = Thread.new do
> |              loop { c1 += 1 }
> |            end
> |        b = Thread.new do
> |              loop { c2 += 1 }
> |            end
> |        b.priority = 99999
> |        sleep 1
> |        Thread.critical = 1
> |        p c1  # => 347111
> |        p c2  # => 343477
> |
> |
> |Am I missing something?
> 
> No, there was a bug.  But when the bug is fixed this program hangs,
> since thread b goes to inifinite loop with higher priority.  There's
> no chance for other threads to run.

But if I change it to:

        Thread.current.priority = 2
        b.priority = 1
        sleep 1

would it run? And if so, would the c1 be zero at the end?