Add missing thread locking