Introduction to Multithreading
• When we run a program , the running program is called ‘Process’
• A running program(process) will have its own ow of control
• When a single process is running then its called “uni-tasking”
• When more than one process is running then its called “Multitasking”
• If two programs are running simultaneously then theses two programs will have
its own ow of control
• Hardware( CPU) will execute some lines of program 1 then some lines of
program 2 then again 1 then 2 so on… this gives us the impression that they
are running simultaneously but only one core I.e, CPU will execute these
programs at a time
fl
fl
• Multithreading is same as multitasking but the di erence is , in a main
program they are sub independent program that run simultaneously and each
sub program is having its own ow control.
• A process is a heavy process , but a thread is a light weighted process because
they are children of main program.
Advantages of Multithreading :
- We can create animations
- We can create games
- Chatting between multiple users
- Providing web services for multiple clients connected to the server at a time
fl
ff