# What is the difference between \`Threads.@spawn\` and \`Distributed.@spawnnat\`

**URL:** https://discourse.julialang.org/t/what-is-the-difference-between-threads-spawn-and-distributed-spawnnat/35560
**Category:** General Usage
**Tags:** question, parallel
**Created:** [March 5, 2020, 8:27am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-threads-spawn-and-distributed-spawnnat/35560 "2020-03-05T08:27:07Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [March 5, 2020, 8:35am UTC](https://discourse.julialang.org/t/what-is-the-difference-between-threads-spawn-and-distributed-spawnnat/35560/2 "2020-03-05T08:35:46Z")

</div>

Distributed is for running computation on _workers_, i.e., separate instances of julia running either locally or remote. Threads are local to your CPU. Threads have less overhead, but require you to think about thread safety. Distributed computing scales to many machines, clusters, the cloud etc., but communication between the main process and the workers can limit the performance for some tasks and code must be available on all participating machines etc.

I hope that gives you an idea.

Threads are used for stuff like

- Matrix multiplication
- Speeding up loops involving somewhat expensive computations.

Distributed for stuff like:

- Many parallel MC simulations that take long time each
- Very expensive computations that take very long time in relation to how long time it takes to send data to the worker.
- Very large, distributed linear algebra or optimization

---

_[View the full topic](https://discourse.julialang.org/t/what-is-the-difference-between-threads-spawn-and-distributed-spawnnat/35560)._
