# Delay

**URL:** <https://rubytalk.org/t/delay/25665>\
**Category:** ruby-talk\
**Created:** [11 March 2006 14:25 UTC](https://rubytalk.org/t/delay/25665 "2006-03-11T14:25:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TURK](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@TURK](https://rubytalk.org/u/TURK)\
**Post date:** [11 March 2006 14:25 UTC](https://rubytalk.org/t/delay/25665/1 "2006-03-11T14:25:27Z")

</div>

HI masters,  
I want to create a loop say :

while (i\>=0)  
// do something  
Now hang for two seconds for next iteration  
i-=i  
}

How would you hang the process in ruby for a certain time?  
thank you

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Daniel\_Harple](https://avatars.discourse-cdn.com/v4/letter/d/5daacb/32.png) [@Daniel\_Harple](https://rubytalk.org/u/Daniel_Harple)\
**Post date:** [11 March 2006 14:28 UTC](https://rubytalk.org/t/delay/25665/2 "2006-03-11T14:28:08Z")

</div>

Use Kernel#sleep

-- Daniel

> **···**
>
> On Mar 11, 2006, at 3:25 PM, TURK wrote:
> 
> > HI masters,  
> > I want to create a loop say :
> > 
> > while (i\>=0)  
> > // do something  
> > Now hang for two seconds for next iteration  
> > i-=i  
> > }
> > 
> > How would you hang the process in ruby for a certain time?  
> > thank you
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
