Make threading.Lock optional

Single threaded apps does not need to use thread locking