Multiprocessing vs Threading Python
multiprocessing, multithreading, python
Solution
The `threading` module uses threads, the `multiprocessing` module uses processes. The difference is that threads run in the same memory space, while processes have separate memory. This makes it a bit harder to share objects between processes with multiprocessing. Since threads use the same memory, precautions have to be taken or two threads will write to the same memory at the same time. This is what the global interpreter lock is for.
Spawning processes is a bit slower than spawning threads.
Problem
I am trying to understand the advantages of multiprocessing over threading. I know that multiprocessing gets around the Global Interpreter Lock, but what other advantages are there, and can threading not do the same thing?
Related problems
- What is the difference between concurrency and parallelism?
- What is the global interpreter lock (GIL) in CPython?
- How can I explicitly free memory in Python?
- What are the differences between the threading and multiprocessing modules?
- What do 'real', 'user' and 'sys' mean in the output of time(1)?
- What are the differences between the threading and multiprocessing modules?