# Manage tasks from Threads.@spawn without using map()

**URL:** <https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493>\
**Category:** General Usage\
**Tags:** parallel, multithreading, threads\
**Created:** [August 22, 2024, 5:00pm UTC](https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493 "2024-08-22T17:00:25Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [August 24, 2024, 7:58am UTC](https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493/12 "2024-08-24T07:58:36Z")

</div>

> [@abraemer](#):
>
> > [@felipe\_1](#):
> >
> > `cur_id = findall(x->x==val, vec_reference)`
> 
> Here you should use `findfirst(x->x==val, vec_reference)` to just get first index (which is also the only index).
> 
> ``

Or better yet, keep `vec_reference` sorted, and use `searchsortedfirst`.

---

_[View the full topic](https://discourse.julialang.org/t/manage-tasks-from-threads-spawn-without-using-map/118493)._
