2010/2/15 Mido Peace <mido.peace / gmail.com>:
> Hi,
> I have a trouble using the ConditionVariable and Mutex Class ,
> Actualy , I'm tryin' to make a Semaphore to manage Threads
> a simple semaphore with its 2 famous methods looks like :
>
> def acquire()
>
> =A0 =A0raise "Interrupted Thread " if (!Thread.current.alive?)
> =A0 =A0 / mutex.synchronize {
> =A0 =A0 while @permits < 1
> =A0 =A0 =A0 @cv.wait(@mutex)
> =A0 =A0 end
> =A0 =A0@permits =3D @permits - 1
> =A0 =A0}
> end
>
>
> def release()
> =A0 =A0 / mutex.synchronize{
>
> =A0 =A0 =A0@permits +=3D 1
> =A0 =A0 =A0 / cv.signal
>
> =A0 =A0 =A0}
>
> end
>
>
> But When I call The acquire Method later
>
> I get : `wait': stopping only thread (ThreadError)
>
> SomeOne has an idea ??

Not without the full code.  What you showed looks OK.

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/