Thread array

  • Thread starter Thread starter Ricardo
  • Start date Start date
You mean an array of threads?

My first suggestion is always to look at the ThreadPool class in the
System.Threading namespace. If that won't suit your needs, perhaps you
are trying to do something like the following?

static void Main(string[] args)
{
Thread[] threads = new Thread[5];

for(int i = 0; i < threads.Length; i++)
{
threads = new Thread(new ThreadStart(DoWork));
}

for(int i = 0; i < threads.Length; i++)
{
threads.Start();
}

for(int i = 0; i < threads.Length; i++)
{
threads.Join();
}

Console.WriteLine("Complete");
}

static void DoWork()
{
Console.WriteLine("DoWork");
}

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top