python3学习手册
tag("jobxx") def scheduler_thread(): while True: schedule.run_pending() time.sleep(1) # 启动调度器线程 thread = threading.Thread(target=scheduler_thread) thread.start() schedule.run_all() ★第16章、多进程与多线程 ★多进程mul�processing.Process类 python多进程(mul�-process)适用于计算密集型的任务, 对于I/O密集型任务应该使用多线程(mul�-thread),比如磁盘读写, 网络通信等 在python中,对于计算密集型任务,多进程占优势;对于IO密集型任 务,多线程占优势。 使用多进程时,各进程拥有独立的内存空间,无法共享内存空间,所 以 ★多线程threading.Thread类 python多线程(mul�-thread)适用于I/O密集型的任务, 对于计算密集型任务应该使用多进程(mul�-process) Python3有两个标准库 _thread 和 threading 提供对线程的支持 python2为thread和threading模块 ★简单线程_thread模块 import _thread import time0 码力 | 213 页 | 3.53 MB | 1 年前3
共 1 条
- 1