I'm creating a threading.Timer(2,work)
run threads. Inside each work function, upon some condition the global counter must increment without conflict for access of counter variable among the spawned work threads.
I've tried Queue.Queue
assigned counter as well as threading.Lock()
. Which is a best way to implement thread-safe global increment variable.
Previously someone asked question here: Python threading. How do I lock a thread?
See Question&Answers more detail:os