Wednesday, February 1, 2017

Difference Between Thread and Task

1. Task can return a result while using thread there is no direct mechanism to return result.
2. Wait on a set of tasks, without using signalling construct.
3. You can chain tasks together to execute one after another.
4. Task support cancellation through the use of cancellation tokens.
5. Asynchronous implementation is easy in task, using’ async’ and ‘await’ keywords.
6.. If system has multiple tasks then it use the CLR thread pool internally. And do not have overhead for creating dedicated thread. Also reduce the context switching among multiple thread.

No comments: