摘要:
Python 对并行化支持的名声就不是很好,如果你用过 Python 自带的线程库 thread 和 threading,你应该知道 Python 线程其实并不好用。例如:没有自带的获取线程返回值的方法,需要自己重写自己的threading。
目录:
正文:
一. Python 多线程 基础
1.1 thread 模块
# -*- coding: UTF-8 -*-
import thread
import time
# 为线程定义一个函数
def print_time( threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print