From: Jamis Buck Date: 2004-09-12T02:23:15+09:00 Subject: Re: Net-SSH Threaded PortForward Script Problems otaku wrote: > Justin, > > 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. -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis "I use octal until I get to 8, and then I switch to decimal."