Lock ByNameMap to make it thread safe.