# How to turn off @threads for ... while debugging

**URL:** <https://discourse.julialang.org/t/how-to-turn-off-threads-for-while-debugging/57234>\
**Category:** New to Julia\
**Tags:** threads\
**Created:** [March 15, 2021, 8:55pm UTC](https://discourse.julialang.org/t/how-to-turn-off-threads-for-while-debugging/57234 "2021-03-15T20:55:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asyrov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asyrov/32/13578_2.png) [@asyrov](https://discourse.julialang.org/u/asyrov)\
**Post date:** [March 15, 2021, 8:55pm UTC](https://discourse.julialang.org/t/how-to-turn-off-threads-for-while-debugging/57234/1 "2021-03-15T20:55:31Z")

</div>

I’d like to turn off (like it is nothing) @threads macro in some case while debugging. Such as I want to pass optional parameter `use_threads`, and then how would I modify the following code not to use threads (possibly without introducing if-then everywhere)?

```julia
@threads for i in eachidex(...)
    do something
end

```

Thank you very much in advance

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [March 15, 2021, 9:26pm UTC](https://discourse.julialang.org/t/how-to-turn-off-threads-for-while-debugging/57234/2 "2021-03-15T21:26:50Z")

</div>

You could create a, say, `@maybethreads` macro which depending on a global switch does the same thing as `@threads` or nothing, respectively. See [@assert alternatives? - #14 by WschW](https://discourse.julialang.org/t/assert-alternatives/24775/14) for a similar example. You might also want to check out [https://github.com/KristofferC/TimerOutputs.jl/blob/master/README.md#overhead](https://github.com/KristofferC/TimerOutputs.jl/blob/master/README.md#overhead).
