in Technology by
What are the difference between Task and Thread in .NET?

1 Answer

0 votes
by
  • 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.

Related questions

0 votes
    What's the difference between SDK and Runtime in .NET Core?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What is the difference between .NET Core and Mono?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What are some characteristics of .NET Core?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What is included in .NET Core?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    Can ASP.NET Core work with the .NET framework?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What are the benefits of Explicit Compilation (AOT)?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What is CoreCLR?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What is CTS?...
asked Feb 16, 2023 in Technology by JackTerrance
0 votes
    What Is The Difference Between A Verilog Task And A Verilog Function?...
asked Dec 12, 2020 in Technology by JackTerrance
0 votes
    What is the difference between HttpContext.Current.Items and HttpContext.Current.Session in ASP.NET?...
asked Apr 7, 2021 in Education by JackTerrance
0 votes
    What is the proper technique to have ThreadA signal ThreadB of some event, without having ThreadB sit ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    What is the proper technique to have ThreadA signal ThreadB of some event, without having ThreadB sit ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    Differentiate between the Thread class and Runnable interface for creating a Thread?...
asked Jan 19, 2021 in Technology by JackTerrance
0 votes
    Differentiate between process and thread?...
asked Jan 19, 2021 in Technology by JackTerrance
0 votes
    What are the differences between ASP.NET Web Service and WCF?...
asked Jul 26, 2021 in Technology by JackTerrance
...