Câu hỏi phỏng vấn C#
Câu hỏi

Explain the difference between Task and Thread in .NET

Câu trả lời

Difference between Task and Thread in .NET

In .NET, both Task and Thread are used for asynchronous programming, but they have some key differences:

Thread

  • A Thread is a unit of execution within a process.
  • Threads are managed by the operating system's scheduler.
  • Threads can be created using the Thread class from the System.Threading namespace.
  • Threads are low-level constructs that provide direct access to the operating system's threading capabilities.
  • Threads require more system resources (memory, CPU time) compared to Tasks.
  • Threads can be used for both CPU-bound and I/O-bound operations.

Task

  • A Task is a higher-level abstraction over Threads.
  • Tasks are managed by the Task Parallel Library (TPL) in .NET.
  • Tasks can be created using the Task class ...
middle

middle

Gợi ý câu hỏi phỏng vấn

expert

What is deep or shallow copy concept in C#?

junior

What are Reference Types in C#?

senior

What is the difference between System.ApplicationException class and System.SystemException class?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào