Creating the multiple threads that call same function with different sleep interval
How to create multiple threads that call same function with different sleep interval
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
vishvanath shindePosted Aug 29, 2009, 12:58 PM
Just wanted to know the difference between 'Thread thread1 = new Thread(new ThreadStart(ThreadFunction));' and
'Thread thread1 = new Thread(DisplayThread1);'?
Kirtan PatelPosted Aug 19, 2009, 2:40 AM
Here I Have Created Two Thread Each Will Sleep for 100 Mili Seconds and Print the Line :)
dont forget to mark "Do you like answer" if answer helped you . It will Give me Some Credit :)
class Program
{
static void Main(string[] args)
{
Thread t1 = new Thread(MyFunc);
t1.Name = "T1";
t1.Start();
Thread t2 = new Thread(MyFunc);
t2.Name = "T2";
t2.Start();
Console.ReadKey();
}
public static void MyFunc()
{
for (int i = 0; i <= 10; i++)
{
if (Thread.CurrentThread.Name != null)
{
Console.Write("Printed From "+Thread.CurrentThread.Name+"\n");
}
Thread.Sleep(100);
}
}
}