Multi Threading in Dot net..

First we understand the differences b/w Multitasking Multiprocessing and Multi-Threading.

Multitasking: An Operating system provides to perform multiple task to user at a time that is called multitasking. For e.g. you sing song on VLC player while working on MS office.



These are two types concept in Multitasking
1.    Multi-Processing
2.    Multi-Threading

Multiprocessing : Computer system's ability to support more than one process or program at the same time. Multiprocessing operating systems enable several programs to run concurrently. UNIX is one of them. Multiprocessing systems are much more complicated than single-process systems because the operating system must allocate resources to competing processes in a reasonable manner. It refers to the utilization of multiple CPU's in a single computer system. This is also called parallel processing.


Multithreading : A thread is defined as the execution path of a program. Thread are used to run application that perform large and complex computations. Other ways you can say thread is smallest unit of code that dispatched to C.P.U. for execution. If multiple threads are dispatched to C P U to run all thread parallel is call multitasking programming. For e.g - CPU  performs various complex tasks simultaneously .The  process include three different  tasks such as listening  songs with media player, installing software and  writing with ms office .All the process are handled  by separate threads.

Single-Threaded Application : A process that is executed using one thread is known as a single-thread-process. A single-threaded application can perform only one task at a time. Means you have wait for one task to complete before another task can start.
Multi-Threaded Application: A process that create two or more threads is called multi-threaded-process.

Threads vs. Processes : A thread is analogous to the operating system process in which your application runs. Just as processes run in parallel on a computer, threads run in parallel within a single process. Processes are fully isolated from each other; threads have just a limited degree of isolation. In particular, threads share (heap) memory with other threads running in the same application. This, in part, is why threading is useful: one thread can fetch data in the background, for instance, while another thread can display the data as it arrives.

Thread States : Life Cycle of a Thread - 
Thread has one of several thread states this section discusses these states and the transitions between states. Two classes critical for multithreaded applications are Thread and Monitor (System. Threading namespace). This section also discusses several methods of classes Thread and Monitor that cause state transitions.
A new thread begins its life-cycle in the Un-started state. The thread remains in the Un-started state until the program calls Thread method Start, which places the thread in the Started state (sometimes called the Ready or Run able state) and immediately returns control to the calling thread. Then the thread that invoked Start, the newly Started thread and any other threads in the program execute concurrently.

 Type of Several Thread State in C# .Net
·         UnStarted: Thread is created within the common language run time but not started still.
·         Running: After a Thread calls Start method.
·         Wait/Sleep/Join: After a Thread calls its wait or Sleep or Join method.
·         Resume: causes the suspended Thread to resume its execution.
·         Suspended: Thread responds to a Suspend method call.
·         Stopped: The Thread is Stopped, either normally or Aborted.

Comments

Popular posts from this blog

Artificial Intelligence

Smart Card

Biometrics