# -*- coding: utf-8 -*- import threading, time g_count = 0 class testThread(threading.Thread): def run(self): global g_count for i in range(100): lock.acquire() g_count += 1 lock.release() time.sleep(0) lock = threading.Lock() testThreads = [] for i in range(100): th = testThread() th.start() testThreads.append(th) for th in testThreads: th.join() print g_count