Interview Question

Task vs Thread?

A thread is an execution resource; a task models asynchronous work.

💡 Concept ✅ Quick Revision 🔷 C#

Answer

A Thread represents an operating-system execution thread, while a Task represents an asynchronous operation. • A task may run on a thread-pool thread, complete through I/O, or finish synchronously. • Tasks compose through await, continuations, cancellation, and result propagation. • Create a dedicated thread only when its thread identity or lifetime is specifically required.

💡 C# Example

Task<int> calculation = Task.Run(() => 6 * 7); Console.WriteLine(await calculation);

Output

42

⚡ Quick Revision

A thread is an execution resource; a task models asynchronous work.