3 Key difference between multi-threading and multitasking?

In the programming world, there are two main ways to improve the throughput of a program,  by using multi-threading and by using multitasking. Both take advantage of parallelism to efficiently utilize immense power of CPU and improve the throughput of your program. Actually, multi-threading is nothing but a thread based multi-tasking. Since the difference between multi-threading and multi-tasking is an important freshers programming interview question and also often ask in viva or oral exams on computer science graduation courses, I thought to jot down a couple of important points together. This article is the result of those points and can be handy when you quickly wants to know the key difference between multi-threading and multi-tasking in concurrent programming.



Difference between multithreading and multi-tasking

1) In multitasking, several programs are executed concurrently e.g. Java compiler and a Java IDE like Netbeans or Eclipse, while in multi-threading multiple threads execute either same or different part of program multiple times at the same time.


2) Multi-threading is more granular than multi-tasking. In multi-tasking,  CPU switches between multiple programs to complete their execution in real time, while in multi-threading CPU switches between multiple threads of the same program. Remember, switching between multiple processes has more context switching cost than switching between multiple threads of the same program.

3) Process are heavyweight as compared to threads, they require their own address space, which means multi-tasking is heavy compared to multithreading. Inter-process communication is expensive and limited and context switching from one process to another is expensive and limited.  See difference between a Process and a Thread to learn more.

Here is the summary of difference between multitasking and multithreading in concurrent programming:

Difference between multithreading and multitasking


That's all about the difference between multitasking and multithreading. Both are used to parallelize things in order to take full advantage of expensive hardware and CPU.  Multitasking is an ability of a computer to execute multiple programs at the same time while multi-threading is the ability of a process to execute multiple threads at the same time.  Sometimes multitasking is useful and other time multi-threading.


No comments:

Post a Comment