What’s the difference between multiprocessing and multithreading?

331 views

What’s the difference between multiprocessing and multithreading?

In: 194

17 Answers

Anonymous 0 Comments

Old OSs like DOS would run only one app, you would run it, work in it and close it to work with another app. Modern OSs can run multiple apps (processes) at the same time hence the name multiprocessing. This is how you can run a browser and excel together. They can’t directly communicate, unless they are designed to do so (this part is oversimplified and omits many things like debuggers and viruses), or user decides to transfer some data between them (copy paste for example)

Now, every application has a thread, in apps with a user interface it is called GUI thread. This thread receives mouse, keyboard, and all possible input from the OS, processes them, and displays results in GUI thread. What you see as applications are actually threads running.

Everything is ok, every application is running smoothly but you decided to download a file in the browser, an it froze because it has one thread and that single thread has to wait the download to finish so it can do other things like respond to cancel download button. It cannot even draw its page or menu or anything really, its single thread is busy downloading the file. Only if there was a way to download it while keeping GUI thread free. Someone said let’s create another thread in this process for other tasks, so GUI thread can work stress free. Processes can create and terminate threads as they please, but if GUI thread is terminated, app is closed. Also threads can communicate with each other since they are in the same app.

In this sense you can think processes as restaurants. A single business entity with multiple workers so each worker can work on a different aspect of the business.

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