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

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

问题描述

在C#4.0中,我们有任务在System.Threading.Tasks命名空间。是什么主题和任务之间的真正差别。我做了一些示例程序(帮助从MSDN获得)为我自己的缘故

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.

我已初步搜查了#1类似类型的问题,但可能与此问题的标题我是不是能够得到相同的。如果有人知道这里早先被张贴在同一类型的问题,请给该链接的参考。

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术语中,任务重新presents异步操作。螺纹(s)作为通过破坏工作成块,并分配给单独的线程来完成该操作。

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天全站免登陆