What’s the difference between multiprocessing and multithreading?

319 views

What’s the difference between multiprocessing and multithreading?

In: 194

17 Answers

Anonymous 0 Comments

The other answers here are inaccurate, and missing one critical aspect — a process has its own memory segment that cannot typically be accessed by other processes. Multiple threads within a process can share the same memory. Multiprocessing needs to coordinate the communication between processes, usually with memory-mapped files or by using sockets. In some cases, like with a debugger, you can access the memory of another process but usually this is out of bounds and you can configure your system to disallow it.

Multiprocessor hardware architectures are another thing altogether. Some of the other answers are confusing that with multiprocessing which is a software topic. You can technically have multiple processes on one physical processor, and it’s multiprocessing if they are working together to do a related task.

For the baker analogy, the recipes are processes, the ovens and mixers are processors. You could have multiple threads for part of the work (e.g. mixing dry ingredients and wet ingredients at the same time before they get combined) and some work needs to be done in serial, like mixing the final batter and then putting it in the oven. This is also assuming the oven can only fit one baked good at a time, or you’d have to think of it as processor = cake sized volume in the oven, or 1 rack in the oven, or similar.

You are viewing 1 out of 17 answers, click here to view all answers.