71. What is multithreading?
Running multiple threads concurrently to improve application responsiveness.
72. What is the difference between a thread and a task?
- Thread: OS-level unit of execution
- Task: .NET abstraction over asynchronous work, managed by the thread pool
73. What is the async keyword?
Marks a method as asynchronous, allowing await calls inside it.
74. What is the await keyword?
Pauses execution of an async method until the awaited task completes, without blocking the thread.
75. Difference between Task and ValueTask?
- Task: always allocates an object
- ValueTask: avoids allocation for high-performance scenarios
76. What is a deadlock?
Two or more threads waiting on each other indefinitely, preventing progress.
77. How do you prevent deadlocks?
- Avoid nested locks
- Use
async/awaitproperly - Minimize lock duration
78. What is a thread pool?
A pool of reusable threads managed by .NET to reduce the cost of thread creation.
79. Difference between lock and Monitor?
lockis syntactic sugar forMonitor.EnterandMonitor.Exit.- Monitor provides more advanced features like
WaitandPulse.
80. What is CancellationToken?
Used to cancel tasks or async operations cooperatively.