# Difference between multiprocessors and multithreads

**URL:** <https://discourse.julialang.org/t/difference-between-multiprocessors-and-multithreads/87884>\
**Category:** General Usage\
**Tags:** parallel, multithreading, distributed\
**Created:** [September 27, 2022, 6:50pm UTC](https://discourse.julialang.org/t/difference-between-multiprocessors-and-multithreads/87884 "2022-09-27T18:50:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisutich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisutich/32/33342_2.png) [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Post date:** [September 27, 2022, 6:50pm UTC](https://discourse.julialang.org/t/difference-between-multiprocessors-and-multithreads/87884/1 "2022-09-27T18:50:46Z")

</div>

Hi,

I used to use package `Distributed` to do parallel computation. I may require multiple processors by `addprocs()` and use `pmap` to execute a function `f` on multiple cpus. But I just realize that Julia also provides multithreads as in [https://docs.julialang.org/en/v1/manual/multi-threading/](https://docs.julialang.org/en/v1/manual/multi-threading/) . Due to my very limited knowledge, I am very confused about this. What is the difference between multithreads and the way I used to use? How to decide which one to use?

Thanks

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 27, 2022, 7:11pm UTC](https://discourse.julialang.org/t/difference-between-multiprocessors-and-multithreads/87884/2 "2022-09-27T19:11:36Z")

</div>

> [@jisutich](#):
>
> Due to my very limited knowledge, I am very confused about this. What is the difference between multithreads and the way I used to use?

Google “shared memory vs distributed memory parallelism” or “threads vs processes” and similar things and you will find lots of explainers — this is not specific to Julia.

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [September 27, 2022, 7:13pm UTC](https://discourse.julialang.org/t/difference-between-multiprocessors-and-multithreads/87884/3 "2022-09-27T19:13:18Z")

</div>

Super Short Answer : (wikipedia will give you better info)

MT deal with parallelism inside a processor with multiple threads (light process) concurrently **sharing the same memory.** These concurrent threads may (or may not) be executed in parallel by the multiple cores of the processor.  
PROS : much less latency → you can parallelize task with a relatively small workloads  
CONS #1: difficult and dangerous (data races) → you may use parallel patterns such as ThreadsX.jl by @tkf.  
CONS #2: You cannot scale to interconnected processors (cluster) as you can with Distributed computing.

Combination of Distributed parallelism and MT inside processors is common.
