Protect initial resource scanning with mutex.