http://stackoverflow.com/questions/4130194/what-is-the-difference-between-task-and-thread

回答一:

A task is something you want done.

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

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.

回答2:

In computer science terms, a Task is a future or a promise. (Some people use those two terms synomymously, some use them differently, nobody can agree on a precise definition.) Basically, a Task<T> "promises" to return you a T, but not right now honey, I'm kinda busy, why don't you come back later?

Thread is a way of fulfilling that promise. But not every Task needs a brand-new Thread. (In fact, creating a thread is often undesirable, because doing so is much more expensive than re-using an existing thread from the threadpool. More on that in a moment.) If the value you are waiting for comes from the filesystem or a database or the network, then there is no need for a thread to sit around and wait for the data when it can be servicing other requests. Instead, the Task might register a callback to receive the value(s) when they're ready.

In particular, the Task does not say why it is that it takes such a long time to return the value. It mightbe that it takes a long time to compute, or it might that it takes a long time to fetch. Only in the former case would you use a Thread to run a Task. (In .NET, threads are freaking expensive, so you generally want to avoid them as much as possible and really only use them if you want to run multiple heavy computations on multiple CPUs. For example, in Windows, a thread weighs 12 KiByte (I think), in Linux, a thread weighs as little as 4 KiByte, in Erlang/BEAM even just 400 Byte. In .NET, it's 1 MiByte!)

最新文章

  1. 【原】小玩node+express爬虫-1
  2. pem转换成der
  3. 精通 CSS 选择器
  4. 泛型中? super T和? extends T的区别
  5. ListView 完全优化 + 多种listitem布局处理
  6. CentOS 6.5/6.6 安装mysql 5.7 最完整版教程
  7. Convention插件
  8. C#生成日期流水账号
  9. storm 随机发送字符串
  10. misc设备
  11. Hibernate中的集合映射
  12. 3、SQL基础整理(分组)
  13. usb mass storage之旅
  14. 转:JS线程和JS阻塞页面加载的问题
  15. 为什么OC语言很难
  16. hashMap遍历方式
  17. github pages + Hexo + 域名绑定搭建个人博客
  18. openstack2 kvm
  19. USI和USCI的区别
  20. what&#39;s the 二叉树

热门文章

  1. 把多种验证规则用到一个model上
  2. 用最简单的脚本完成supertab的基本功能并实现一个更加合理的功能
  3. String数据类型转换
  4. JNI数组操作
  5. PC、h5项目接入第三方支付宝扫码登录、扫码付款
  6. ES6 作用域的问题
  7. join 和 left join 和 right join的区别?
  8. What is the difference between rhel 6 and rhel7
  9. 《啊哈算法》中P81解救小哈
  10. unigui的session【1】