# Sleep() in processing

**URL:** <https://discourse.processing.org/t/sleep-in-processing/21966>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 17, 2020, 7:31pm UTC](https://discourse.processing.org/t/sleep-in-processing/21966 "2020-06-17T19:31:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeyeffkay](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jeyeffkay](https://discourse.processing.org/u/jeyeffkay)\
**Post date:** [June 17, 2020, 7:31pm UTC](https://discourse.processing.org/t/sleep-in-processing/21966/1 "2020-06-17T19:31:27Z")

</div>

Hey guys,

I am currently coding on a game for school and I asked myself and googled how can I use the sleep() command in processing. I want to create a flappy bird like game and I want one loop to wait e.g. two seconds before it continues. Any ideas?

Greetings and thank you for response  
Jeyeffkay

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [June 17, 2020, 8:35pm UTC](https://discourse.processing.org/t/sleep-in-processing/21966/2 "2020-06-17T20:35:17Z")

</div>

Hi @jeyeffkay,

Using “sleep()” is often not the best option to wait for something to happen because you’ll completely freeze your program during the sleeping time.

Instead you want to use [millis()](https://processing.org/reference/millis_.html) to check how much time elapsed since the last time you entered your draw loop and do something only if 2 seconds have passed.

There are plenty of exemple of that concept on the forum and I’m pretty sure you’ll find a nice example that will suit your situation.

---

<div class="post-metadata">

**Author:** ![jeyeffkay](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jeyeffkay](https://discourse.processing.org/u/jeyeffkay)\
**Post date:** [June 17, 2020, 8:54pm UTC](https://discourse.processing.org/t/sleep-in-processing/21966/3 "2020-06-17T20:54:32Z")

</div>

Thank you very much  
I hope, I’ll find a suitable answer
