From: Paul Brannan Date: 2002-06-07T22:35:58+09:00 Subject: Re: 1-second events On Fri, Jun 07, 2002 at 09:25:48AM +0900, Nobuyoshi Nakada wrote: > This is based on yours. > > def periodically(sec, *args) > loop do > t = Thread.new {sleep sec} > yield(*args) > t.join > end > end > > periodically 1.0 do > p Time.now > sleep 0.5 > end I like the simplicity of this solution. But if I change: p Time.now to puts "#{Time.now.tv_sec}.#{Time.now.tv_usec}" then I see quite a lot of drift: 1023456778.810465 1023456779.815316 1023456780.825325 1023456781.835464 1023456782.845571 1023456783.855783 1023456784.865900 1023456785.876033 1023456786.886212 1023456787.896280 1023456788.896795 1023456789.906567 1023456790.916710 Over the course of a day I would expect to eventually lose a second. Paul