From: Louis-Philippe Date: 2008-12-04T11:43:07+09:00 Subject: Re: New to ruby, using threads ------=_Part_21925_4410102.1228358935673 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline hi Poncho, what you want to do is probably have two parallel threads, so, try something like: t1 = Thread.new do while true do puts "Starting new job at #{Time.now}" sleep 3 end end t2 = Thread.new do loop do do_something end end t1.join 2008/12/3 Poncho Quintanilla > I'm trying to schedule some task using ruby threads > > This work great: > > t = Thread.new do > while true do > puts "Starting new job at #{Time.now}" > do_something > sleep 3 > end > end > t.join > > But when the task take a long, like: > > def do_something > puts "doing something at#{Time.now}" > sleep(rand(3)) > end > > I cant get the "Starting new job" message appears in regular intervals > of 3 seconds. What I'm missing? > > Thanks > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_21925_4410102.1228358935673--