How to make npc autospawn?

can somebody tell me? I am making a gamemode where zombies spawn and i was wondering how.