copy ConditionVariable from thread.rb