一.多线程 1.顺序执行单个线程,注意要顺序执行的话,需要用join. #coding=utf-8 from threading import Thread import time def my_counter(): i = 0 for _ in range(100000000): i = i + 1 return True def main(): thread_array = {} start_time = time.time() for tid in range(2): t = Thread
import time,threading print("=======串行方式.并行两种方式调用run()函数=======")def run(): print('哈哈哈') #串行for i in range(5): run() #并行for i in range(5): t = threading.Thread(target=run) #实例化了一个线程 t.start() print("======串行.并行方式统计网页下载时间=======") impor