The concept of executing multiple functionalities simultaneously is known as multitasking.
Public static void main (string args [ ])
MSD s1 = new MSD ();
S1. Fun 1();
S1. Fun 2 ();
S1. Fun 3 ();
If we apply, the concept of multitasking to our program, then control flow would be as follows:
- A part of fun 1() will be executed and then control switches to fun 2(). Now here also a part of fun2 () is executed and then control; switches to fun 3().
- A part of fun 3() is executed and then control again comes back to fun 1(). Now it continues executing fun 1() from where it had stopped earlier. Similarly fun 2()( and fun 3().
- Now, when we see the output, we feel that the processor is executing the three functionalities simultaneously. Thus, the concept of multitasking came into existence to avoid the idle state of CPU.
- In multitasking, we said that a part of the functionality is executed one at a time. Now, the question is part means how many statements. This conflict is resolved by scheduling.
- Remember that processor is also an electronic circuit and it any instant of a time, it can execute only one statement.
- It cannot execute multiple statements simultaneously.
The Advantages of multitasking:
- Multitasking was invented to avoid Idle states of CPU
- But interestingly, it is used to make the functions get executed independently.
- Animation along with form submission is a very good example of multitasking.
Actually, in real time we use multitasking to make the most of the second advantage rather than the first because, in the case of small projects, the idle state of CPU is not a big concern.