using ParameterizedThreadStart in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
public static void Main()
{
System.Threading.Thread t = new Thread(new ParameterizedThreadStart(threadmethod));
t.Start(5);
t.Join();
}
public static void threadmethod(object o)
{
for (int i = 0; i <(int)o; i++)
{
Console.WriteLine("Thread method proc {0}",i);
System.Threading.Thread.Sleep(500);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
public static void Main()
{
System.Threading.Thread t = new Thread(new ParameterizedThreadStart(threadmethod));
t.Start(5);
t.Join();
}
public static void threadmethod(object o)
{
for (int i = 0; i <(int)o; i++)
{
Console.WriteLine("Thread method proc {0}",i);
System.Threading.Thread.Sleep(500);
}
}
}
}
result:
Thread method proc 0
Thread method proc 1
Thread method proc 2
Thread method proc 3
Thread method proc 4
Press any key to continue . . .
No comments