Qus:    Differentiate between Task and Thread in .NET.
Oct 15, 2020 08:46 2 Answers Views: 142 ANANYA

1) Task is more abstract then threads. It is always advised to use tasks instead of thread as it is created on the thread pool which has already system created threads to improve the performance.



2) The task can return a result. There is no direct mechanism to return the result from a thread.



3) Task supports cancellation through the use of cancellation tokens. But Thread doesn't.



4) A task can have multiple processes happening at the same time. Threads can only have one task running at a time.

Prev Next
Answers (2)
NAIDU Oct 16, 2020 02:51
Answer:   Thread represents an actual OS-level thread, with its own stack and kernel resources, and allows the highest degree of control. You can choose to Abort() or Suspend() or Resume() a thread, and set thread-level properties, like the stack size, apartment state, or culture. While a Task class from the Task Parallel Library is executed by a TaskScheduler to return a result and allows you to find out when it finishes.

PARTH Oct 16, 2020 08:10
Answer:   1) Task is more abstract then threads. It is always advised to use tasks instead of thread as it is created on the thread pool which has already system created threads to improve the performance.

2) The task can return a result. There is no direct mechanism to return the result from a thread.

3) Task supports cancellation through the use of cancellation tokens. But Thread doesn't.

4) A task can have multiple processes happening at the same time. Threads can only have one task running at a time.

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect