# Julia Multithreading (Threads.@threads) and Travis CI

**URL:** <https://discourse.julialang.org/t/julia-multithreading-threads-threads-and-travis-ci/16468>\
**Category:** General Usage\
**Tags:** package, multithreading, travis\
**Created:** [October 17, 2018, 10:44pm UTC](https://discourse.julialang.org/t/julia-multithreading-threads-threads-and-travis-ci/16468 "2018-10-17T22:44:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [October 17, 2018, 10:44pm UTC](https://discourse.julialang.org/t/julia-multithreading-threads-threads-and-travis-ci/16468/1 "2018-10-17T22:44:53Z")

</div>

Hi all,

in a number of packages I started experimenting with code that exploits Julia’s multithreading facilities, i.e. mainly the `Threads.@threads` macro. I am a bit confused as to how to enable automatic testing of my code using Travis CI, in particular, to enable multithreading on Travis, but also to test both with and without multithreading (i.e. once with `Threads.nthreads() == 1` and once with `Threads.nthreads()>1`). Is anybody aware of an example `travis.yml` configuration file that I could look into?

Thanks,

Jutho

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [October 17, 2018, 11:23pm UTC](https://discourse.julialang.org/t/julia-multithreading-threads-threads-and-travis-ci/16468/2 "2018-10-17T23:23:17Z")

</div>

How about setting the environment variable like this? (untested)

```yaml
env:
  matrix:
    - JULIA_NUM_THREADS=1
    - JULIA_NUM_THREADS=2

```

see: [Environment Variables - Travis CI](https://docs.travis-ci.com/user/environment-variables/)

---

<div class="post-metadata">

**Author:** ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)\
**Post date:** [October 18, 2018, 8:17pm UTC](https://discourse.julialang.org/t/julia-multithreading-threads-threads-and-travis-ci/16468/3 "2018-10-18T20:17:10Z")

</div>

Thanks, works perfectly!
