#!/usr/bin/ruby
# Signals
require 'thread'
mutex = Mutex.new
cv = ConditionVariable.new
puts "Process 1"
a = Thread.new {
mutex.synchronize {
puts "A: Wait For Signal"
cv.wait(mutex)
puts "A: All done!"
}
}
puts "Process 2"
b = Thread.new {
mutex.synchronize {
puts "B: Sending signal to A"
cv.signal
puts "B: All done!"
}
}
a.join
b.join
Ruby Справочник v0.05 © 2007-2024 Igor Salnikov aka SunDoctor