Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to make threads in c# and execute them. Looking for Producer-Consumer Program in c#
Posted

 
Share this answer
 
ThreadStart ts = new ThreadStart(MethodName);
Thread.Start(ts);
 
Share this answer
 
I don't know what are you up to. But here are some of the sample codes to clarify you how threading works.

C#
Class Test
{
static void main()
{
Thread t=new Thread(WriteB);
t.Start();

for(int i=0; i<1000; i++)
{
Console.Write("A");
}
}

static void WriteB()
{
for (int(i=0; i<1000; i++)
{
Console.Write("Y");
}
}

}


I hope this would help you.
If you have any confusion, you are free to ask me.
 
Share this answer
 
Comments
Zain ul abdeen 23-Mar-13 13:18pm    
I was trying to know the basics of threading this helped abd now I want to learn multithreading and locking algorithms

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900