2026在线视频总结工具免费版哪个好用?实测多款后整理了实用选购参考
2026/6/11 6:17:52
from log import * import threading import time # 共享资源 counter = 0 lock = threading.Lock() def increment(): global counter lock.acquire() try: counter += 1 info("CUrrent thread: {}, Counter: {}".format(threading.current_thread().name, counter)) finally: # 释放锁 lock.release() # 创建10个线程 threads = [] for _ in range(10): t = threading.Thread(target=increment) threads.append(t) t.start() # 等待所有线程完成 for t in threads: t.join()