Sunday, December 19, 2010

understanding the multithreading in Console Application.

Multithreading helps to perform various operations simultaneously and saves time of a user. A multithreaded program has a main thread and other user-defined threads to perform multiple tasks simultaneously.
The microprocessor allocates memory to the processes that you execute. Each process occupies its own address space or memory. However, all the threads in a process occupy the same address space. Multithreading allows you to achieve multitasking in a program. Multitasking is the ability to execute more than one task at the same time.  
Multitasking can be divided into the two categories:

•    Process-based multitasking: - This multitasking feature enables you to switch from one program to another so fast that it appears as if the programs are executing at the same time. For example, process-based multitasking enables you to run the c# compiler and use the text editor at the same time.

•    Thread-based multitasking: - A single program can contain two or more threads and therefore, perform two or more tasks simultaneously. For example, a text editor can perform writing to a file and print a document simultaneously with separate threads performing the writing and printing actions. In the text-editor, you can format text in a document and print the document at the same time. There are fewer overloads when the processor switches from one thread to another. Therefore, threads are called lightweight processes. On the other hand, when the processor switches from one process to another process the overload increases.

No comments:

Recent Posts