问题描述
关于如何在Python中使用线程的一般教程或很好的资源?
General tutorial or good resource on how to use threads in Python?
何时使用线程,它们如何有效以及线程的某些一般背景知识(特定于Python)?
When to use threads, how they are effective, and some general background on threads [specific to Python]?
推荐答案
如果您希望同时运行两件事,或者希望某件事在后台运行而又不减慢主进程的速度,则应使用线程.
我的建议是仅在必要时使用线程.它们通常会增加程序的复杂性.
线程的主要文档在这里: http://docs.python.org/library/threading. html
一些示例在这里:
http://www.devshed.com/c /a/Python/Python中的基本线程/1/
http://linuxgazette.net/107/pai.html
http://www.wellho.net/solutions/python-python-threads-a-first-example.html
Threads should be used when you want two things to run at once, or want something to run in the background without slowing down the main process.
My recommendation is to only use threads if you have to. They generally add complexity to a program.
The main documentation for threading is here: http://docs.python.org/library/threading.html
Some examples are here:
http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/1/
http://linuxgazette.net/107/pai.html
http://www.wellho.net/solutions/python-python-threads-a-first-example.html
这篇关于Python中的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!