Share the mutex when generating multiple ids