From: "Vishnu I." Date: 2011-01-06T19:54:17+09:00 Subject: Re: Threading in ruby Robert Klemme wrote in post #972756: > On Thu, Jan 6, 2011 at 10:28 AM, Vishnu I. wrote: >>> The solution without queue would involve a ConditionVariable. This is >>> more appropriate than using sleep: >>> >>> https://gist.github.com/764540#file_sc2.rb >> >> ah I see. So does each wait get the corresponding signal? so if I have >> 10 signals queued up, the next 10 waits can operate instantly? > > signals are not queued. All threads waiting on the condition are > signalled (and woken up) - if there is no thread waiting, none is > woken up. But that is not needed because of the condition and > looping. The client will continue to work until the condition is > false. The CV only serves the purpose to wake up threads should they > go out of work to do. > > Btw, I recommend Doug Lea's book - it's about Java but concepts > described there like thread confinement have broader validity. > > Kind regards > > robert hmm ok Im confused now. Say the main thread completes really quickly and fires available.signal 10 times in 2 minutes. Meanwhile say the updater has only updated twice. Wont the third update wait forever since there is no one left to signal? -- Posted via http://www.ruby-forum.com/.