Senior .Net Developer Question:

Download Job Interview Questions and Answers PDF

What is the difference between Task and Thread in .NET?

Senior .Net Developer Interview Question
Senior .Net Developer Interview Question

Answer:

☛ Thread represents an actual OS-level thread, with its own stack and kernel resources. Thread allows the highest degree of control; you can Abort() or Suspend() or Resume() a thread, you can observe its state, and you can set thread-level properties like the stack size, apartment state, or culture. ThreadPool is a wrapper around a pool of threads maintained by the CLR.

☛ The Task class from the Task Parallel Library offers the best of both worlds. Like the ThreadPool, a task does not create its own OS thread. Instead, tasks are executed by a TaskScheduler; the default scheduler simply runs on the ThreadPool. Unlike the ThreadPool, Task also allows you to find out when it finishes, and (via the generic Task) to return a result.

Download Senior .Net Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Please explain what is the difference between encrypting a password and applying a hashing?What is the difference between boxing and unboxing?