use lock instead of RLock