Professional Documents
Culture Documents
KARTHIKEYAN R
18Y023
What are to be discussed:
► What is threading
► Synchronous and asynchronous
► Using of threads
► Methods of threads
► Thread Join
► Thread Sleep
► Thread Abort
Threading
Step 1:
First and foremost step is to import the Threading namespace.
using System;
using System.Threading
Step 2:
Here in this step we will create thread objects
in our Main method.
class Program
{
static void Main(string[] args)
{
Thread oThreadone =new
Thread(Work1);
Thread oThreadtwo = new
Thread(Work2);
}
}
Step 3:
In this step we will invoke our thread objects
class Program
{
static void Main(string[] args)
{
Thread oThreadone = new Thread(Work1);
Thread oThreadtwo = new Thread(Work2);
oThreadone.Start();
oThreadtwo.Start();
}
}
• As you see, we have invoked Thread
objects successfully.
• Now, let's run this program to see the
Output.....
• As you can see, in the output,
method Work2 is simultaneously
executing along with the method
Work1.
• It means that both of these
methods are working
asynchronously.
THREAD.Sleep