# Multithreading of a simple loop

**URL:** <https://discourse.julialang.org/t/multithreading-of-a-simple-loop/49478>\
**Category:** Performance\
**Tags:** performance, multithreading\
**Created:** [November 2, 2020, 8:29pm UTC](https://discourse.julialang.org/t/multithreading-of-a-simple-loop/49478 "2020-11-02T20:29:43Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [November 2, 2020, 9:21pm UTC](https://discourse.julialang.org/t/multithreading-of-a-simple-loop/49478/5 "2020-11-02T21:21:22Z")

</div>

The problem is `CSV.write` functions. They take much longer time than actual data generation and affected by `IO`. By removing all lines after the loop (starting from `df1 = DataFrame(V_id)` up to return) I get the following numbers:

```julia
@btime run_singlethread(3, 10000)
# 1.847 ms (30006 allocations: 3.59 MiB)
@btime multithread_run(3, 10000)
# 814.549 μs (40051 allocations: 4.05 MiB)

```

---

_[View the full topic](https://discourse.julialang.org/t/multithreading-of-a-simple-loop/49478)._
