![]() |
VOOZH | about |
In C#, we can schedule a thread for execution using the Thread class. The Thread.Start() method is responsible for scheduling a thread, allowing it to run when system resources are available. This method can be overloaded to pass parameters to the thread. Also, the Thread.Sleep() method can be used to pause execution for a specified duration.
The Start() method changes the state of the current instance to Running, allowing the thread to execute its assigned task.
Syntax:
public void Start();
Exceptions:
Example:
0 1 2 3
This method starts the execution of a thread and allows passing an object containing data to be used by the method the thread executes.
Syntax:
public void Start(object parameter);
Exceptions:
Example:
Data of Thread 1 is: 1 Data of Thread 2 is: Hello
The Thread.Sleep() method pauses the execution of the current thread for a specified duration, allowing other threads to execute.
Syntax:
public static void Sleep(int millisecondsTimeout);
Example:
Starting... 300 milliseconds have passed.