i am not sure the syntax is correct
however its looking like perhaps you may be correct
in regard to the race condition
the Programming Ruby book provides an example of using mutex
require 'thread'
mutex = Mutex.new
count1 = count2 = 0
difference = 0
counter = Thread.new do
loop do
mutex.synchronize do
count1 += 1
count2 += 1
end
end
end
spy = Thread.new do
loop do
mutex.synchronize do
difference += (count1 - count2).abs
end
end
end
i am not sure the syntax is correct
however its looking like perhaps you may be correct
in regard to the race condition
the Programming Ruby book provides an example of using mutex
[snip]
You want more than just a mutex, though--you need a condition variable. The CV lets you wait until some other condition has been satisfied (it's useful for helping to prevent deadlocks):
require 'thread'
m = Mutex.new
cv = ConditionVariable.new
Thread.new do
m.synchronize do
# do some work
cv.signal
end
end
# wait until the cv is signaled
m.synchronize { cv.wait( m ) }
Justin was saying you need to use a condition variable to let your program know that the threads have all started properly, and are ready to accept connections.