一、threading模块
multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性。
1.开启线程的两种方式(同Process)
方法一
from threading import Threadimport timedef sayhi(name):
time.sleep(2) print('%s say hello' %name)if __name__ == '__main__':
t=Thread(target=sayhi,args=('hh',))
t.start() print('主线程')主线程 hh say hello


