Robert Klemme wrote in post #964651:
> On Mon, Nov 29, 2010 at 10:51 AM, Alex Young <alex / blackkettle.org>
> wrote:
>>
>>  Thread.start do
>> end
>> $ ruby a.rb
>> ConditionVariable instead of MonitorMixin, so is there any way to ensure
>> that the thread scheduling goes as [t2,t1,t3] *or* [t3,t1,t2], but never
>> [t2,t3,t1]?
>
> Yes, this is intentional behavior.  There are no guarantees with
> regard to timing and order in which threads obtain the monitor.  This
> means especially that thread 2 and 3 can obtain any number of times
> before thread 1 runs again.
>

That's what I thought, ok.

> Please note also that the intended usage of condition variables is
> different: you obtain a lock then you loop while the condition is not
> reached and then you continue.  This is what you rather want if you
> want to ensure alternation:
<snip>

Perfect, thanks. I'll give that a try.

--
Alex

-- 
Posted via http://www.ruby-forum.com/.