Multithread - ParameterizedThreadStart Delegate

Recall that the ThreadStart delegate can point only to methods that return void and take no arguments. But if you wish to pass data to the method executing on the secondary thread, you will need to make use of the ParameterizedThreadStart delegate type. To begin, import the System.Threading namespace. Now, given that ParameterizedThreadStart can point to any method taking a System.Object parameter.
using System;
using System.Threading;

class Program
{
    static void Main()
    {
	// Create an array of Thread references.
	Thread[] array = new Thread[6];
	for (int i = 0; i < array.Length; i++)
	{
	    // Start the thread with a ParameterizedThreadStart.
	    ParameterizedThreadStart start = new ParameterizedThreadStart(Start);
	    array[i] = new Thread(start);
	    array[i].Start(i);
	}

	// Join all the threads.
	for (int i = 0; i < array.Length; i++)
	{
	    array[i].Join();
	}

	Console.WriteLine("DONE");
    }

    static void Start(object info)
    {
	// This receives the value passed into the Thread.Start method.
	int value = (int)info;
	Console.WriteLine(value);
    }
}

Output:

1 2 0 3 5 4 In this example, the threads were called in a non-sequential order. This is because there is some indeterminate pause before the OS and Framework can receive a thread, and by that time we may have already requested another thread.