任务和线程有什么区别? [英] What is the difference between task and thread?

查看:31
本文介绍了任务和线程有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 4.0 中,我们在 System.Threading.Tasks 命名空间中有 Task.ThreadTask 之间的真正区别是什么.为了自己学习

In C# 4.0, we have Task in the System.Threading.Tasks namespace. What is the true difference between Thread and Task. I did some sample program(help taken from MSDN) for my own sake of learning with

Parallel.Invoke 
Parallel.For 
Parallel.ForEach 

但有很多疑问,因为想法不是那么清楚.

but have many doubts as the idea is not so clear.

我最初在 Stackoverflow 中搜索了类似类型的问题,但可能由于这个问题标题我无法得到相同的问题.如果有人知道之前在这里发布的同一类型的问题,请提供链接的参考.

I have initially searched in Stackoverflow for a similar type of question but may be with this question title I was not able to get the same. If anyone knows about the same type of question being posted here earlier, kindly give the reference of the link.

推荐答案

任务就是你想要完成的事情.

A task is something you want done.

线程是执行该任务的众多可能工作线程之一.

A thread is one of the many possible workers which performs that task.

在 .NET 4.0 术语中,任务代表异步手术.线程用于通过将工作分解为块并分配给单独的线程来完成该操作.

In .NET 4.0 terms, a Task represents an asynchronous operation. Thread(s) are used to complete that operation by breaking the work up into chunks and assigning to separate threads.

这篇关于任务和线程有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆