import threading # 執行緒模塊 def function(num): pass thread_1 = threading.Thread(target=function, args=(1,)) # 創建執行緒 thread_1.start() # 啟動執行緒 thread_1.getName() # 獲取執行緒名 thread_1.join() # 執行緒阻塞,等待完成當前執行緒在開始執行下一個 lock = threading.Lock() # 初始化執行緒鎖 lock.acquire() # 執行緒加鎖 lock.release() # 執行緒鎖釋放 with lock: # 自動釋放執行緒鎖 pass # 業務代碼
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/93492.html
標籤:Python
