Causes the operating system to change the state of the current instance to ThreadState.Running.
Type Reason OutOfMemoryException There is not enough memory available to start the thread. NullReferenceException This method was invoked on a null thread reference. System.Threading.ThreadStateException The thread has already been started.
Once a thread is in the ThreadState.Running state, the operating system can schedule it for execution. The thread begins executing at the first line of the method represented by the System.Threading.ThreadStart or System.Threading.ParameterizedThreadStart delegate supplied to the thread constructor.
If this overload is used with a thread created using a System.Threading.ParameterizedThreadStart delegate, null is passed to the method executed by the thread.
Once the thread terminates, it cannot be restarted with another call to Start.
The following example demonstrates creating a thread and starting it.
C# Example
using System; using System.Threading; public class ThreadWork { public static void DoWork() { for (int i = 0; i<3;i++) { Console.WriteLine ("Working thread ..."); Thread.Sleep(100); } } } class ThreadTest{ public static void Main() { ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); for (int i = 0; i<3; i++) { Console.WriteLine("In main."); Thread.Sleep(100); } } }
One possible set of output is
In main.Note that the sequence of the output statements is not guaranteed to be identical across systems.