# Spawn task on thread after delay and fetch result later

**URL:** <https://discourse.julialang.org/t/spawn-task-on-thread-after-delay-and-fetch-result-later/63051>\
**Category:** General Usage\
**Created:** [June 16, 2021, 9:57pm UTC](https://discourse.julialang.org/t/spawn-task-on-thread-after-delay-and-fetch-result-later/63051 "2021-06-16T21:57:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [June 16, 2021, 9:57pm UTC](https://discourse.julialang.org/t/spawn-task-on-thread-after-delay-and-fetch-result-later/63051/1 "2021-06-16T21:57:32Z")

</div>

I am trying to execute a function on a different thread after a specified delay. I could use `Timer`, but I need to fetch the result. As shown below, my solution was to use sleep. I was wondering if this is there are better approaches.

```julia
import Base.Threads: @spawn

function run_at(f, delay)
    sleep(delay)
    return f()
end

f() = sum(rand(10000))

t1 = @spawn run_at(f, 3)
fetch(t1)

```
