From: Earle Clubb Date: 2007-08-31T04:14:18+09:00 Subject: Changing date backward messes up threaded sleep Can anyone explain this behavior? If the system time is set backward, the sleep method in the thread sleeps until the system clock has caught back up to the original time. The main thread does not display this behavior. The following script demonstrates the issue (run as root or sudo): -------------------- #!/usr/bin/ruby -w t = Thread.new do 20.times do |i| puts "TH:#{Time.now}" sleep 1 end end 20.times do |i| puts "MN:#{Time.now}" sleep 1 if i == 5 now=Time.now now+=ARGV[0].to_f puts "Changing time to: #{now}" `date -s "#{now}"` end end t.join -------------------- Running the script with and arg of -4 causes the thread to sleep for 5 seconds after the time change, but the main thread keeps on ticking along. An arg of +4 causes no problems. Earle -- Posted via http://www.ruby-forum.com/.