c#中多线程与多任务区别
The computer programming term "thread" is short for thread of execution, in which a processor follows a specified path through your code. The concept of following more than one thread at a time introduces the subject of multi-tasking and multi-threading.
计算机编程术语“线程”是执行线程的缩写,其中处理器遵循代码中的指定路径。 一次跟踪多个线程的概念引入了多任务和多线程的主题。
An application has one or more processes in it. Think of a process as a program running on your computer. Now each process has one or more threads. A game application might have a thread to load resources from disk, another to do AI, and another to run the game as a server.
一个应用程序中包含一个或多个进程。 可以将进程视为在计算机上运行的程序。 现在,每个进程都有一个或多个线程。 一个游戏应用程序可能具有一个线程来从磁盘加载资源,另一个可以执行AI,另一个可以作为服务器运行游戏。
In .NET/Windows, the operating system allocates processor time to a thread. Each thread keeps track of exception handlers and the priority at which it runs, and it has somewhere to save the thread context until it runs. Thread context is the information that the thread needs to resume.
在.NET / Windows中,操作系统将处理器时间分配给线程。 每个线程都会跟踪异常处理程序及其运行的优先级,并且在某个地方可以保存线程上下文,直到运行为止。 线程上下文是线程需要恢复的信息。
线程多任务 ( Multi-Tasking With Threads )
Threads take up a bit of memory and creating them takes a little time, so usually, you don't want to use many. Remember, they compete for processor time. If your computer has multiple CP