Add lock on IdGenerator