What is the difference between multi-threading and multi-processing?


#1

Can some one give me simple examples between both


#2

A thread is a stream of instructions within a process. Each thread has its own instruction pointer, set of registers and stack memory. The virtual address space is process specific, or common to all threads within a process. So, data on the heap can be readily accessed by all threads, for good or ill.

Multi-threading is a more “light weight” form of concurrency: there is less context per thread than per process. As a result thread lifetime, context switching and synchronisation costs are lower. The shared address space (noted above) means data sharing requires no extra work.

Multi-processing has the opposite benefits. Since processes are insulated from each other by the OS, an error in one process cannot bring down another process. Contrast this with multi-threading, in which an error in one thread can bring down all the threads in the process. Further, individual processes may run as different users and have different permissions.


#3

*In multiprocessing processes are executed concurrently, and in multithreading threads of a single process are executed concurrently.

  • Multiprocessing has more CPUs whereas multithreading creates a number of threads of the process allowing its simultaneous execution for increasing computing power.

#4

Multi threading:

  1. Multi threading creates multiple thread of a single process to increase computing power.
  2. Multiple threads of a single process are executed concurrently.
  3. Creation of a thread is economical in both sense time and resource.
  4. Multi threading is not classified.

Multi processing:

  1. Multi processing adds CPUs to increase computing power.
  2. Multi processes are executed concurrently.
  3. creation of process is time consuming and resourse intensive.
  4. Multi processing can be symmetric or asymmetric.