# Toggle Threads.@threads with a variable

**URL:** https://discourse.julialang.org/t/toggle-threads-threads-with-a-variable/71818
**Category:** General Usage
**Created:** [November 20, 2021, 9:24am UTC](https://discourse.julialang.org/t/toggle-threads-threads-with-a-variable/71818 "2021-11-20T09:24:39Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [November 20, 2021, 11:34pm UTC](https://discourse.julialang.org/t/toggle-threads-threads-with-a-variable/71818/6 "2021-11-20T23:34:00Z")

</div>

For a _runtime_ flag, I recently rolled my own solution at [https://github.com/JuliaQuantumControl/QuantumControlBase.jl/blob/master/src/conditionalthreads.jl](https://github.com/JuliaQuantumControl/QuantumControlBase.jl/blob/master/src/conditionalthreads.jl), as discussed in [Optional macro invocation - #21 by goerz](https://discourse.julialang.org/t/optional-macro-invocation/18588/21)

---

_[View the full topic](https://discourse.julialang.org/t/toggle-threads-threads-with-a-variable/71818)._
