线程,异步编程和并行之间有什么区别 [英] what does different between Thread , Asynchronous Programming and Parallel

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

问题描述


请告诉我Thread,异步编程和并行有什么区别.

用C#编程.

谢谢

Hi
Please tell me what''s the difference between Thread , Asynchronous Programming and Parallel.

Programming in c#.

Thank you

推荐答案

.NET Framework为您提供了几种使用多个执行线程的方法,以使您的应用程序对用户保持响应,同时最大程度地提高用户的性能.的计算机.

并行编程模型将使您的代码并行化,以在多个处理器之间分配工作.在异步过程中,应用程序可以继续进行其他不依赖于Web资源的工作,直到潜在的阻塞任务完成为止.

有关详细信息,请参见此处: MSDN:.NET Framework中的并行处理和并发 [ ^ ]
The .NET Framework provides several ways for you to use multiple threads of execution to keep your application responsive to your user while maximizing the performance of your user''s computer.

Parallel programming model is to Parallelize your code to distribute work across multiple processors WHEREAS In an asynchronous process, the application can continue with other work that doesn''t depend on the web resource until the potentially blocking task finishes.

Refer here for details: MSDN: Parallel Processing and Concurrency in the .NET Framework[^]


线程是异步和并行编程的一种手段.真正的问题是异步编程和并行编程之间的区别是什么.
此处是博客 [
A Thread is a means to Async and Parallel programming. The real question is what is the difference between Async and Parallel programming.
Here''s a blog[^] that explains it pretty well.
Here''s the short of it:
Both Async and Parallel programming are methods to run code without blocking your UI (or main) thread
When you''re programming Async you execute code on a different thread which prevents the UI from becoming unresponsive.
When you''re doing Parallel programming you''re doing multiple things at the same time. For example, you want to read all the files in a single folder on your file system. You could spawn a new thread for each file, which is theoretically faster than reading one file after another.
To illustrate the difference, in Async programming you could have the files being read one after another (so not parallel), but still do this on a different thread, so your UI stays responsive.
Also notice that the two are not mutually exclusive. You could spawn a thread to read the files (Async) and then read an x amount of files at the same time (Parallel).
I hope that clears things up for you :)


您需要首先解决完全不同的问题.这是关于您提出正确问题的技巧.这个问题是完全不正确的.我对解释这些基本内容感到很尴尬,但请看一下我过去的回答:
类与封装之间的区别是什么编程 [ ^ ].

请参阅以下讨论:
如何问一个好问题? [代码项目常见问题解答 [如何使用Google和其他查找编程的技巧帮助 [ ^ ]
在论坛中发布问题的一些准则 [ ^ ].

请先阅读它们,然后再继续.

—SA
You need to solve completely different problem first. This is about your skills to ask correct question. This question is totally incorrect. I feel awkward to explain such elementary things, but please look at my past answer:
what is the difference between the class and encapsulation in programming[^].

Please see also this discussion:
How to ask a good question?[^].

Did you follow these directions for asking questions?

Code Project Questions and Answers FAQ[^]
How to Use Google and Other Tips for Finding Programming Help[^]
Some guidelines for posting questions in the forums[^].

Please, read them before you proceed.

—SA


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

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