标签:start bsp style tar gil div color print 多线程
查看当前线程
开启新的线程
import threading def worker(): print(‘new thread..‘) print(threading.current_thread().getName()) if __name__ == ‘__main__‘: print(‘hello‘) t = threading.current_thread() print(t.getName()) # MainThread th1 = threading.Thread(target=worker, name=‘my Thread‘) th1.start()
细粒度锁:主动加的锁
粗粒度锁:解释器加的锁 GIL
标签:start bsp style tar gil div color print 多线程
原文地址:https://www.cnblogs.com/zhuxiang1633/p/9335001.html