32.1.1. Ruby timer or timed event handling?

From Lyle Johnson

I'll bet there's a better way, but what about creating a thread sleeps thirty seconds in between doing its thing?

th = Thread.new do
    loop do
        puts "I just did something, going back to sleep now!
        sleep(5)
    end
end
Licence Creative Commons
Tento dokument Ruby, jehož autorem je Radek Hnilica, podléhá licenci Creative Commons Uveďte autora-Nevyužívejte dílo komerčně-Zachovejte licenci 3.0 Česká republika .