Thursday, 8 March 2012

Threading Basics

•Dividing a single program into multiple parts and executing those parts concurrently is called “MultiThreading”. Each part of the program is called a “thread”.
•A thread defines a separate path of execution.
•Java supports multithreading.

Multitasking vs Multithreading:


•Java supports multithreading.
•In single threaded systems, there is only a single thread of execution.
•The single threaded systems follow the event loop with polling model.
•In this model the single thread waits for an event to be polled. When an event is polled, control is passed to the respective event handler. The control is returned back only when the event handler completes its execution.
•The disadvantage of single threaded systems is wastage of CPU cycles.
•So, to increase the efficiency of the CPU we use multithreading.
•In this, several threads run parallely. If one thread is blocked, other threads continue to run. Thus the wastage of CPU cycles is eliminated.

No comments:

Post a Comment