# Is there a way to return from a function from within a thread?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-return-from-a-function-from-within-a-thread/35656>\
**Category:** General Usage\
**Tags:** parallel, threads\
**Created:** [March 6, 2020, 6:39pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-return-from-a-function-from-within-a-thread/35656 "2020-03-06T18:39:07Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 16, 2023, 11:15am UTC](https://discourse.julialang.org/t/is-there-a-way-to-return-from-a-function-from-within-a-thread/35656/13 "2023-04-16T11:15:17Z")

</div>

There has been this other recent thread: [How to early return from inside a @threads loop](https://discourse.julialang.org/t/how-to-early-return-from-inside-a-threads-loop/97457)

(I think the safest way to deal with that is to use a flag to exit from the workload of the chunk assigned to each thread, splitted at a higher level)

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-way-to-return-from-a-function-from-within-a-thread/35656)._
