@Monster sorry for my late response; I see rayman22201 already answered your question. I think it's a good habit to declare the globals immediately. My code was just to experiment with Locks and Conditions; I personally avoid globals.
@rayman22201 It was fun-stuff I have to work now with databases, but also locking stuff and dealing with deadlocks @mratsim thank you for your interesting additions