C# Interview Question #66

What is a thread in C#?

Async/Await, Tasks & Multithreading Mid-Level Intermediate

Quick Interview Answer

A thread is an execution path within a process. Multiple threads can execute work concurrently.

Detailed Explanation

A thread is an execution path within a process. Multiple threads can execute work concurrently.

.NET provides Thread for low-level thread management, but most modern application code should use higher-level abstractions such as Task, the thread pool, async/await, Parallel APIs, and concurrent collections.

Creating dedicated threads has a higher cost and is rarely necessary in normal ASP.NET Core request processing.

Code Example

Thread thread = new Thread(() =>
{
    Console.WriteLine("Work running");
});

thread.Start();
thread.Join();