什么是线程以及如何在.net中使用它

问题描述:

朋友您好,



我有4年的开发Web应用程序的经验。但是,我不知道什么是线程?然后如何使用?



在这种情况下我使用的是Thread.Sleep方法。



在很多文章中我都看到了线程这个词。请给我解决方案以了解线程以及我们应该使用线程的情况。



非常感谢您的帮助。谢谢

Hello friends ,

I have 4 year experience in developing web application. But , i don't know what is threading ? and then how to use that ?

In such cases i am used Thread.Sleep method.

In many article i see the word threading. Please give me solution to understand about thread and which cases we should be use thread.

Your help very appreciated. Thanks

这是一个非常广泛的问题,所以完全回答它是不可能的。考虑线程的一种方法是使用线程可以在程序中同时执行操作。



当程序可以从线程中受益时,有很多情况。一个简单的想法是,如果你有多个处理器,你可以分割一个长操作,从而缩短执行时间。另一个例子可能是你有一个包括计算和使用慢资源(如磁盘)的操作。并行执行计算和磁盘访问可能会再次缩短完成操作所需的时间。



要了解线程,我建议从线程化(C#和Visual Basic) [ ^ ]
This is a very broad question so it's quite impossible to answer it in full. One way to think about threading is that with threads you can do operations simultaneously in your program.

There are lots of situations when a program can benefit from threading. A simple thought is that if you have multiple processors you can split a long operation and thus shorten the execution time. Another example could be that you have an operation which includes both computing and using slow resources (like disk). Doing the computing and disk access in parallel may again shorten the time needed to complete the operation.

To get to know threading I suggest starting from Threading (C# and Visual Basic)[^]