def every(period : Time::Span, &block : -> T) forall T spawn do loop do block.call sleep period end end end every(2.seconds) { puts "-@-@-" } every(4.seconds) { puts "(-.-)Zzz..." } sleep