# Run function with delay

**URL:** <https://discourse.julialang.org/t/run-function-with-delay/59404>\
**Category:** General Usage\
**Created:** [April 16, 2021, 11:49am UTC](https://discourse.julialang.org/t/run-function-with-delay/59404 "2021-04-16T11:49:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javise](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@Javise](https://discourse.julialang.org/u/Javise)\
**Post date:** [April 16, 2021, 11:49am UTC](https://discourse.julialang.org/t/run-function-with-delay/59404/1 "2021-04-16T11:49:25Z")

</div>

Hello,

How can I make a function run automatically X seconds after another function has been run (with Pluto) ?

Thank you

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [April 16, 2021, 2:42pm UTC](https://discourse.julialang.org/t/run-function-with-delay/59404/2 "2021-04-16T14:42:26Z")

</div>

Here is how to run `f()` again after 5 seconds. This will block:

```julia
julia> f(); sleep(5); f()
2021-04-16T10:39:55.302
2021-04-16T10:40:00.340

```

This will not block so other functions can run in the meantime:

```julia
julia> f(); @async begin
           sleep(5)
           f()
       end
2021-04-16T10:41:03.714
Task (runnable) @0x0000000073504650

julia> 2^9
512

julia> π
π = 3.1415926535897...

julia> 2021-04-16T10:41:08.722

```
