# How to use multithreads in subthread?

**URL:** <https://discourse.julialang.org/t/how-to-use-multithreads-in-subthread/74470>\
**Category:** General Usage\
**Tags:** question, multithreading\
**Created:** [January 12, 2022, 6:40am UTC](https://discourse.julialang.org/t/how-to-use-multithreads-in-subthread/74470 "2022-01-12T06:40:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![HANHAOHAN](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hanhaohan/32/36366_2.png) [@HANHAOHAN](https://discourse.julialang.org/u/HANHAOHAN)\
**Post date:** [January 12, 2022, 6:40am UTC](https://discourse.julialang.org/t/how-to-use-multithreads-in-subthread/74470/1 "2022-01-12T06:40:47Z")

</div>

```nohighlight
# start with -t 6
function test_threads()
   Threads.@threads for i in 1:100
       @show Threads.threadid()
   end
end
Threads.@spawn test_threads()

```

output as following:  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
Threads.threadid() = 2  
…
