M
Mido Peace
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()
raise "Interrupted Thread " if (!Thread.current.alive?)
@mutex.synchronize {
while @permits < 1
@cv.wait(@mutex)
end
@permits = @permits - 1
}
end
def release()
@mutex.synchronize{
@permits += 1
@cv.signal
}
end
But When I call The acquire Method later
I get : `wait': stopping only thread (ThreadError)
SomeOne has an idea ??
Thx
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()
raise "Interrupted Thread " if (!Thread.current.alive?)
@mutex.synchronize {
while @permits < 1
@cv.wait(@mutex)
end
@permits = @permits - 1
}
end
def release()
@mutex.synchronize{
@permits += 1
@cv.signal
}
end
But When I call The acquire Method later
I get : `wait': stopping only thread (ThreadError)
SomeOne has an idea ??
Thx