thread_running Accessed by Both Threads
A Python module to control the GPIO on a Raspberry Pi
Brought to you by:
croston
It looks to me like add_edge_detect() in the main thread tests thread_running to decide whether to call pthread_create(), and that new thread sets it. But that new thread might not be scheduled for a bit and add_edge_detect() could return, and be called a second time, see thread_running is still false, and call pthread_create() a second time. There may be other variables that need accessing mutually exclusively.