失效链接处理 |
Python Concurrency with asyncio PDF 下载
转载自:
http://www.python222.com/article/314
用户下载说明:
电子版仅供预览,下载后24小时内务必删除,支持正版,喜欢的请购买正版书籍:
http://product.dangdang.com/11163543446.html
相关截图: ![]() 资料内容:
Process
A process is an application run that has a memory space that other applications cannot
access. An example of creating a Python process would be running a simple “hello
world” application or typing python at the command line to start up the REPL (read
eval print loop).
Multiple processes can run on a single machine. If we are on a machine that has a
CPU with multiple cores, we can execute multiple processes at the same time. If we
are on a CPU with only one core, we can still have multiple applications running
simultaneously, through time slicing. When an operating system uses time slicing, it
will switch between which process is running automatically after some amount of time.
The algorithms that determine when this switching occurs are different, depending
on the operating system.
1.4.2 Thread
Threads can be thought of as lighter-weight processes. In addition, they are the small
est construct that can be managed by an operating system. They do not have their own
memory as does a process; instead, they share the memory of the process that created
them. Threads are associated with the process that created them. A process will always
have at least one thread associated with it, usually known as the main thread. A process
can also create other threads, which are more commonly known as worker or back
ground threads. These threads can perform other work concurrently alongside the
main thread. Threads, much like processes, can run alongside one another on a
multi-core CPU, and the operating system can also switch between them via time slic
ing. When we run a normal Python application, we create a process as well as a main
thread that will be responsible for running our Python application.
|