What is differences Between Task And Thread?Explain with example.

Forums C#What is differences Between Task And Thread?Explain with example.
Staff asked 2 years ago

Here is the answer.

 

Karan Rajgor replied 2 years ago

Answers (1)

Add Answer
Karan Rajgor Marked As Accepted
Staff answered 2 years ago

Thread

In C#, the Thread class produces a real operating system thread. The Thread class uses resources like memory for the stack and CPU overhead for context shifts from one thread to another to generate a thread.

In Simple words, Thread gives you full control over any process or program that you are running.

Task

In C#, a Task class is used to define an asynchronous system-level task. Tasks generated with the Task class are executed by the task scheduler. The job is run by the default scheduler inside the thread pool. Tasks, unlike threads generated with the Thread class, do not require any additional memory or CPU resources.

I hope you will like my answer.😄

Subscribe

Select Categories