Fix buggy code in thread locking