Sunday, December 19, 2010

Understanding Advantages and limitations of multithreading in Console Application.

Advantages of Multithreading:  


The Advantages of multithreading are:
•    Improved Performance: provides improvement in the performance of the processor by simultaneous execution of computation and the input/output (I/O) operations.
•    Minimized system resource usage: Minimizes the use of system resources by using threads, which share the same address space and belong to the same process.
•    Simultaneous access to multiple applications: Provides access to multiple applications at the same time because of quick context switching among threads.
•    Program structure simplification: Simplifies the structure of complex applications, such as multimedia applications. Each activity can be written in separate methods that makes complex program easy to design and code.

Limitations of multithreading 

The limitations of multithreading are:
•    Race condition: When two or more threads simultaneously access a variable, at least one thread tries to write a value in the variable. This is called the race condition. which is caused by the lack of synchronization between two threads. For example, in a word processor program, there are two threads, one to read from a file and the other to write to a file. The thread to read a file waits for the thread to write before performing its operation. The race condition arises when the thread to read a file, reads the file, before the thread to write to a file performs its operation.
•    Deadlock condition: This condition arises in a computer system when two threads wait for each other to complete their operations before performing their individual action. As a result, the two threads become locked and the program fails. For example, there are two threads, thread A and Thread B. Thread A is waiting for a lock to be released by Thread B, and Thread B is waiting for the lock to be released by Thread A to complete its transaction. This state is a deadlock.
•    Lock starvation: This limitation arises when the execution of a thread is postponed because of its low priority. The .NET runtime environment executes threads based on their priority because the processor can execute only one thread at a time. The thread with a higher priority is executed before the thread with a lower priority.



What Other's are reading.
Identifying the Thread priority in console application.
Creating multiple threads in console Application.
How to Set the Thread priority in C#.
How to Set the Thread priority in C#.

1 comment:

Paul Miller said...

Excellent post!!! The future of .net application development is on positive note. It offers huge career prospects for talented professionals all over the world. Training on .net technology will ensure good salary package. Best DOT NET Training in Chennai | .NET Course in Chennai

Recent Posts