Multi Threading

 “Multi Threading” is one of the rich features of .NET applications.
 Using this feature, the user is able to create multi-threaded applications.
 This concept is introduced in VC++. This is also supported by Java.
 Thread: The thread is a part of the task.
 Using “multi threading”, you can break a complex task in a single application into multiple threads that execute independently of one another.
 Before starting with the understanding of Multi Threading, you should recollect the concept of “Multi-Tasking”.

Multi Tasking:
 Def: Ability of the OS, that is able to perform more than one task, at-a-time (simultaneously).
 As a part of this, OS allocates the CPU clock for each task.

Multi Threading:
 Def: The ability of an application, that is able to perform more than one thread simultaneously is called as “Multi-Threading”.
 In other words, it can be called as “sub form of multi-tasking”.
 Just like multi-tasking, OS allocates the CPU clock for each thread.

Demo on Multi Threading:
Multi threading
Implementation of Multi Threading:
.NET Framework offers a namespace called “System.Threading” for implementation of multi threading.
 Import the API:
using System.Threading;
 Create the Thread Object:
Thread th = new Thread();
 Start the Thread:

Simple Demo on Multi Threading

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace SimpleThreadingDemo
class ThreadingDemo
private void FirstMethod()
for (int i = 1; i <= 300; i++)
Console.Write("i=" + i + " ");
private void SecondMethod()
for (int j = 1; j <= 300; j++)
Console.Write("j=" + j + " ");
public void Display()
Thread th1 = new Thread(FirstMethod);
Thread th2 = new Thread(SecondMethod);
class Program
static void Main(string[] args)
ThreadingDemo td = new ThreadingDemo();
Multi threading