Select from following answers:- Suspended Thread
- Main Thread

- Background Thread
- Foreground Thread
- All Above
When a program in C# starts execution, the main thread is automatically created. The threads created using the Thread class are called the child threads of the main thread. You can access a thread using the CurrentThread property of the Thread class.
The following program demonstrates main thread execution:
using System;
using System.Threading;
namespace MultithreadingApplication
{
class MainThreadProgram
{
static void Main(string[] args)
{
Thread th = Thread.CurrentThread;
th.Name = "MainThread";
Console.WriteLine("This is {0}", th.Name);
Console.ReadKey();
}
}
}
When the above code is compiled and executed, it produces the following result:
Output: This is MainThread
Show Correct Answer
Asked In: Many Interviews |
Alert Moderator